Skip to content

Commit

Permalink
fix(VTreeview): match loading state with opened node
Browse files Browse the repository at this point in the history
  • Loading branch information
jsek committed Aug 28, 2024
1 parent 0b018d9 commit 2b3b2cf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/vuetify/src/labs/VTreeview/VTreeviewChildren.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ export const VTreeviewChildren = genericComponent<new <T extends InternalListIte

const isClickOnOpen = computed(() => props.openOnClick != null ? props.openOnClick : props.selectable)

function checkChildren (item: any) {
function checkChildren (item: any, itemValue: any) {
return new Promise<void>(resolve => {
if (!props.items?.length || !props.loadChildren) return resolve()

if (item?.children?.length === 0) {
isLoading.value = item.value
isLoading.value = itemValue
props.loadChildren(item).then(resolve)

return
Expand All @@ -86,7 +86,7 @@ export const VTreeviewChildren = genericComponent<new <T extends InternalListIte
}

return () => slots.default?.() ?? props.items?.map(({ children, props: itemProps, raw: item }) => {
const loading = isLoading.value === item.value
const loading = isLoading.value === itemProps.value
const slotsWithItem = {
prepend: slotProps => (
<>
Expand Down Expand Up @@ -133,7 +133,7 @@ export const VTreeviewChildren = genericComponent<new <T extends InternalListIte
...activatorProps,
value: itemProps?.value,
onToggleExpand: activatorProps.onClick as any,
onClick: isClickOnOpen.value ? [() => checkChildren(item), activatorProps.onClick] as any : undefined,
onClick: isClickOnOpen.value ? [() => checkChildren(item, itemProps.value), activatorProps.onClick] as any : undefined,
}

return (
Expand Down

0 comments on commit 2b3b2cf

Please sign in to comment.