Skip to content

fix(VTreeview): prevent redundant treeview re-render during open #19968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/vuetify/src/components/VList/VList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const makeVListProps = propsFactory({

'onClick:open': EventProp<[{ id: unknown, value: boolean, path: unknown[] }]>(),
'onClick:select': EventProp<[{ id: unknown, value: boolean, path: unknown[] }]>(),
'onUpdate:opened': EventProp<[]>(),
...makeNestedProps({
selectStrategy: 'single-leaf' as const,
openStrategy: 'list' as const,
Expand Down
7 changes: 4 additions & 3 deletions packages/vuetify/src/labs/VTreeview/VTreeview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useProxiedModel } from '@/composables/proxiedModel'

// Utilities
import { computed, provide, ref, toRef, watch } from 'vue'
import { genericComponent, omit, propsFactory, useRender } from '@/util'
import { genericComponent, getCurrentInstance, omit, propsFactory, useRender } from '@/util'

// Types
import { VTreeviewSymbol } from './shared'
Expand Down Expand Up @@ -59,6 +59,7 @@ export const VTreeview = genericComponent<new <T>(
},

setup (props, { slots }) {
const vm = getCurrentInstance('VTreeview')
const { items } = useListItems(props)
const activeColor = toRef(props, 'activeColor')
const baseColor = toRef(props, 'baseColor')
Expand Down Expand Up @@ -146,7 +147,8 @@ export const VTreeview = genericComponent<new <T>(
})

useRender(() => {
const listProps = VList.filterProps(props)
const listProps = VList.filterProps(vm.vnode.props!)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid non-existing prop being assigned as undefined to VList

If @update:opened="openedListener" is used in Treeview, VList.filterProps(props) is equivalent to <VList :opened="undefined" @update:opened="openedListener">, which breaks VList demo


const treeviewChildrenProps = VTreeviewChildren.filterProps(props)

return (
Expand All @@ -158,7 +160,6 @@ export const VTreeview = genericComponent<new <T>(
props.class,
]}
style={ props.style }
v-model:opened={ opened.value }
v-model:activated={ activated.value }
v-model:selected={ selected.value }
>
Expand Down