Skip to content

Commit

Permalink
fix: menu selectedKeys & openKeys support deep watch
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Mar 23, 2022
1 parent d137971 commit 7bf1e0d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions components/menu/src/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ export default defineComponent({
watch(
() => props.selectedKeys,
selectedKeys => {
mergedSelectedKeys.value = selectedKeys || mergedSelectedKeys.value;
if (selectedKeys) {
mergedSelectedKeys.value = selectedKeys.slice();
}
},
{ immediate: true },
{ immediate: true, deep: true },
);

const selectedSubMenuKeys = ref([]);
Expand Down Expand Up @@ -212,10 +214,10 @@ export default defineComponent({
() => props.openKeys,
(openKeys = mergedOpenKeys.value) => {
if (!shallowEqual(mergedOpenKeys.value, openKeys)) {
mergedOpenKeys.value = openKeys;
mergedOpenKeys.value = openKeys.slice();
}
},
{ immediate: true },
{ immediate: true, deep: true },
);

let timeout: any;
Expand Down

0 comments on commit 7bf1e0d

Please sign in to comment.