Skip to content

Commit 86323a2

Browse files
committed
fix(nested): avoid console warnings when updating items order
fixes #20934
1 parent af20234 commit 86323a2

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { VTreeview } from '../VTreeview'
33

44
// Utilities
5-
import { render, screen, userEvent, waitAnimationFrame, waitIdle } from '@test'
5+
import { render, screen, userEvent, wait, waitAnimationFrame, waitIdle } from '@test'
66
import { nextTick, reactive, ref, shallowRef } from 'vue'
77

88
const items = [
@@ -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,
@@ -378,7 +380,9 @@ export const useNestedItem = (id: MaybeRefOrGetter<unknown>, isDisabled: MaybeRe
378380

379381
onBeforeMount(() => {
380382
if (!parent.isGroupActivator) {
381-
parent.root.register(computedId.value, parent.id.value, toValue(isDisabled), isGroup)
383+
nextTick(() => {
384+
parent.root.register(computedId.value, parent.id.value, toValue(isDisabled), isGroup)
385+
})
382386
}
383387
})
384388

@@ -388,6 +392,15 @@ export const useNestedItem = (id: MaybeRefOrGetter<unknown>, isDisabled: MaybeRe
388392
}
389393
})
390394

395+
watch(computedId, (val, oldVal) => {
396+
if (!parent.isGroupActivator) {
397+
parent.root.unregister(oldVal)
398+
nextTick(() => {
399+
parent.root.register(val, parent.id.value, toValue(isDisabled), isGroup)
400+
})
401+
}
402+
})
403+
391404
isGroup && provide(VNestedSymbol, item)
392405

393406
return item

0 commit comments

Comments
 (0)