From 6a75df0f49fb84e8bb6122a2c250dfa8c4221222 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Thu, 28 Nov 2024 19:23:04 +0100 Subject: [PATCH] Comments --- src/components/ProjectLauncher.astro | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/ProjectLauncher.astro b/src/components/ProjectLauncher.astro index ac41c71..7bc862c 100644 --- a/src/components/ProjectLauncher.astro +++ b/src/components/ProjectLauncher.astro @@ -81,6 +81,16 @@ const { idxUrl, stackblitzUrl, gitpodUrl, codesandboxUrl, menuAlign = 'left' } = } }; + /** When removed from the DOM, remove this instance from the global set of dropdowns. */ + disconnectedCallback() { + const details = this.querySelector('details'); + if (details) DropDown.dropdowns.delete(details); + } + + /** + * When added to the DOM, set up event listeners and add this instance to the global set of + * dropdowns. + */ connectedCallback() { window.removeEventListener('click', DropDown.onWindowClick); window.addEventListener('click', DropDown.onWindowClick); @@ -143,10 +153,6 @@ const { idxUrl, stackblitzUrl, gitpodUrl, codesandboxUrl, menuAlign = 'left' } = }); } } - disconnectedCallback() { - const details = this.querySelector('details'); - if (details) DropDown.dropdowns.delete(details); - } } if (!customElements.get(DropDown.tagName)) {