diff --git a/apps/app/src/components-v2/layout/RightDrawer.vue b/apps/app/src/components-v2/layout/RightDrawer.vue index 8f3feee9..aa6379e7 100644 --- a/apps/app/src/components-v2/layout/RightDrawer.vue +++ b/apps/app/src/components-v2/layout/RightDrawer.vue @@ -141,9 +141,17 @@ const Body = computed(() => resolveDrawerComponent(component.value)) a minimal empty state — this must NOT crash on null (resolveDrawerComponent guarantees null for unknown names). --> + diff --git a/apps/app/src/components-v2/layout/__tests__/RightDrawer.spec.ts b/apps/app/src/components-v2/layout/__tests__/RightDrawer.spec.ts index 045bc758..f55473ed 100644 --- a/apps/app/src/components-v2/layout/__tests__/RightDrawer.spec.ts +++ b/apps/app/src/components-v2/layout/__tests__/RightDrawer.spec.ts @@ -226,4 +226,35 @@ describe('RightDrawer', () => { // Graceful-empty-state text must NOT appear when a component is rendered expect(wrapper.text()).not.toContain('Geen inhoud') }) + + // ------------------------------------------------------------------------- + // 7. Switching the open drawer component swaps the body cleanly + // (the :key="component" remount guard — opening B while A is open + // unmounts A and mounts B; A's DOM/state must not linger). + // ------------------------------------------------------------------------- + + it('remounts the body when the open drawer switches to another component', async () => { + const BodyA = defineComponent({ template: '
A
' }) + const BodyB = defineComponent({ template: '
B
' }) + const nameA = `${PREFIX}BodyA` + const nameB = `${PREFIX}BodyB` + + registerDrawerComponent(nameA, BodyA) + registerDrawerComponent(nameB, BodyB) + + const wrapper = mountDrawer() + const shell = useShellUiStore() + + shell.openDrawer(nameA, { title: 'A' }) + await wrapper.vm.$nextTick() + expect(wrapper.find('.body-a').exists()).toBe(true) + expect(wrapper.find('.body-b').exists()).toBe(false) + + // Switch to B while the drawer is still open — :key change forces a + // full remount so A is gone and B is mounted (no stale A instance). + shell.openDrawer(nameB, { title: 'B' }) + await wrapper.vm.$nextTick() + expect(wrapper.find('.body-b').exists()).toBe(true) + expect(wrapper.find('.body-a').exists()).toBe(false) + }) })