diff --git a/packages/components/menu/src/menu.ts b/packages/components/menu/src/menu.ts index 960f3dfda8..604475c715 100644 --- a/packages/components/menu/src/menu.ts +++ b/packages/components/menu/src/menu.ts @@ -110,8 +110,6 @@ export default defineComponent({ const items = ref({}) const subMenus = ref({}) - const alteredCollapse = ref(false) - // computed const isMenuPopup = computed(() => { return ( @@ -209,14 +207,7 @@ export default defineComponent({ activeIndex.value = item.index initMenu() } else { - // Can't find item when collapsing - // and activeIndex shouldn't be changed when 'collapse' was changed. - // Then reset 'alteredCollapse' immediately. - if (!alteredCollapse.value) { - activeIndex.value = undefined - } else { - alteredCollapse.value = false - } + activeIndex.value = val } } const handleResize = () => { @@ -237,10 +228,7 @@ export default defineComponent({ watch( () => props.collapse, - (value, prev) => { - if (value !== prev) { - alteredCollapse.value = true - } + (value) => { if (value) openedMenus.value = [] } )