From 9b02b0dc2d3a1bcc5f7736d62ba42d193e84d48e Mon Sep 17 00:00:00 2001 From: "Carlos G.B." Date: Sat, 3 Aug 2024 08:46:26 +0200 Subject: [PATCH] fix(click-outside): correctly remove shadow DOM event listeners (#20273) fixes #19616 --- .../click-outside/__tests__/click-outside-shadow-dom.spec.ts | 4 ++-- .../directives/click-outside/__tests__/click-outside.spec.ts | 2 +- packages/vuetify/src/directives/click-outside/index.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/vuetify/src/directives/click-outside/__tests__/click-outside-shadow-dom.spec.ts b/packages/vuetify/src/directives/click-outside/__tests__/click-outside-shadow-dom.spec.ts index 0d5e3d4df4c..b3c95ebe2a8 100644 --- a/packages/vuetify/src/directives/click-outside/__tests__/click-outside-shadow-dom.spec.ts +++ b/packages/vuetify/src/directives/click-outside/__tests__/click-outside-shadow-dom.spec.ts @@ -63,7 +63,7 @@ describe('click-outside.js within the Shadow DOM', () => { const { outsideClickHandler, shadowEl, binding } = bootstrap() expect(window.document.addEventListener).toHaveBeenCalledWith('click', outsideClickHandler, true) - ClickOutside.unmounted(shadowEl, binding) + ClickOutside.beforeUnmount(shadowEl, binding) expect(window.document.removeEventListener).toHaveBeenCalledWith('click', outsideClickHandler, true) }) @@ -71,7 +71,7 @@ describe('click-outside.js within the Shadow DOM', () => { const { shadowClickHandler, shadowRoot, shadowEl, binding } = bootstrap() expect(shadowRoot.addEventListener).toHaveBeenCalledWith('click', shadowClickHandler, true) - ClickOutside.unmounted(shadowEl, binding) + ClickOutside.beforeUnmount(shadowEl, binding) expect(shadowRoot.removeEventListener).toHaveBeenCalledWith('click', shadowClickHandler, true) }) diff --git a/packages/vuetify/src/directives/click-outside/__tests__/click-outside.spec.ts b/packages/vuetify/src/directives/click-outside/__tests__/click-outside.spec.ts index 548fa8ec88f..a19f9d81d45 100644 --- a/packages/vuetify/src/directives/click-outside/__tests__/click-outside.spec.ts +++ b/packages/vuetify/src/directives/click-outside/__tests__/click-outside.spec.ts @@ -44,7 +44,7 @@ describe('v-click-outside', () => { const { clickHandler, el, binding } = bootstrap() expect(window.document.addEventListener).toHaveBeenCalledWith('click', clickHandler, true) - ClickOutside.unmounted(el, binding) + ClickOutside.beforeUnmount(el, binding) expect(window.document.removeEventListener).toHaveBeenCalledWith('click', clickHandler, true) }) diff --git a/packages/vuetify/src/directives/click-outside/index.ts b/packages/vuetify/src/directives/click-outside/index.ts index 175ed9946f2..d8598c3f900 100644 --- a/packages/vuetify/src/directives/click-outside/index.ts +++ b/packages/vuetify/src/directives/click-outside/index.ts @@ -102,7 +102,7 @@ export const ClickOutside = { } }, - unmounted (el: HTMLElement, binding: ClickOutsideDirectiveBinding) { + beforeUnmount (el: HTMLElement, binding: ClickOutsideDirectiveBinding) { if (!el._clickOutside) return handleShadow(el, (app: HTMLElement) => {