Skip to content
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

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

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading