Skip to content

Commit

Permalink
fix(VListItem): wait until beforeMount to set parent open
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Dec 17, 2024
1 parent d4ba559 commit 39e4a50
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/vuetify/src/components/VList/VListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { genOverlays, makeVariantProps, useVariant } from '@/composables/variant
import { Ripple } from '@/directives/ripple'

// Utilities
import { computed, watch } from 'vue'
import { computed, onBeforeMount, watch } from 'vue'
import { deprecate, EventProp, genericComponent, propsFactory, useRender } from '@/util'

// Types
Expand Down Expand Up @@ -149,15 +149,21 @@ export const VListItem = genericComponent<VListItemSlots>()({
variant: props.variant,
}))

// useNestedItem doesn't call register until beforeMount,
// so this can't be an immediate watcher as we don't know parent yet
watch(() => link.isActive?.value, val => {
if (val && parent.value != null) {
if (!val) return
handleActiveLink()
})
onBeforeMount(() => {
if (link.isActive?.value) handleActiveLink()
})
function handleActiveLink () {
if (parent.value != null) {
root.open(parent.value, true)
}

if (val) {
openOnSelect(val)
}
}, { immediate: true })
openOnSelect(true)
}

const { themeClasses } = provideTheme(props)
const { borderClasses } = useBorder(props)
Expand Down

0 comments on commit 39e4a50

Please sign in to comment.