Skip to content

Commit

Permalink
fix(VTreeview): remove redundant treeview re-render during open (#19968)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwu9145 authored Jun 11, 2024
1 parent d8e8a0c commit 9e1cfbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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
8 changes: 5 additions & 3 deletions packages/vuetify/src/labs/VTreeview/VTreeview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ 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 type { ExtractPublicPropTypes } from 'vue'
import { VTreeviewSymbol } from './shared'
import type { VListChildrenSlots } from '@/components/VList/VListChildren'
import type { ListItem } from '@/composables/list-items'
Expand Down Expand Up @@ -59,6 +60,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 +148,8 @@ export const VTreeview = genericComponent<new <T>(
})

useRender(() => {
const listProps = VList.filterProps(props)
const listProps = VList.filterProps(vm.vnode.props! as ExtractPublicPropTypes<typeof makeVTreeviewProps>)

const treeviewChildrenProps = VTreeviewChildren.filterProps(props)

return (
Expand All @@ -158,7 +161,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

0 comments on commit 9e1cfbd

Please sign in to comment.