Skip to content

Commit 0f58f6f

Browse files
committed
fix(nested): avoid console warnings when updating items order
fixes #20934
1 parent ffe0501 commit 0f58f6f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/vuetify/src/components/VTreeview/__tests__/VTreeview.spec.browser.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ describe.each([
648648
/>
649649
))
650650

651+
await nextTick()
651652
search.value = 'j'
652653
await nextTick()
653654
expect(screen.getByText(/Vuetify/)).toBeVisible()

packages/vuetify/src/composables/nested/nested.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useProxiedModel } from '@/composables/proxiedModel'
55
import {
66
computed,
77
inject,
8+
nextTick,
89
onBeforeMount,
910
onBeforeUnmount,
1011
provide,
@@ -13,6 +14,7 @@ import {
1314
toRaw,
1415
toRef,
1516
toValue,
17+
watch,
1618
} from 'vue'
1719
import {
1820
independentActiveStrategy,
@@ -381,7 +383,9 @@ export const useNestedItem = (id: MaybeRefOrGetter<unknown>, isDisabled: MaybeRe
381383

382384
onBeforeMount(() => {
383385
if (!parent.isGroupActivator) {
384-
parent.root.register(computedId.value, parent.id.value, toValue(isDisabled), isGroup)
386+
nextTick(() => {
387+
parent.root.register(computedId.value, parent.id.value, toValue(isDisabled), isGroup)
388+
})
385389
}
386390
})
387391

@@ -391,6 +395,15 @@ export const useNestedItem = (id: MaybeRefOrGetter<unknown>, isDisabled: MaybeRe
391395
}
392396
})
393397

398+
watch(computedId, (val, oldVal) => {
399+
if (!parent.isGroupActivator) {
400+
parent.root.unregister(oldVal)
401+
nextTick(() => {
402+
parent.root.register(val, parent.id.value, toValue(isDisabled), isGroup)
403+
})
404+
}
405+
})
406+
394407
isGroup && provide(VNestedSymbol, item)
395408

396409
return item

0 commit comments

Comments
 (0)