From 07b13d489a9eef9cb3059a4b0f752dda493102a8 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Tue, 20 Feb 2024 14:07:28 -0500 Subject: [PATCH] reorder --- src/components/select/select.component.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/select/select.component.ts b/src/components/select/select.component.ts index a0ea2f530f..bffebfe5e4 100644 --- a/src/components/select/select.component.ts +++ b/src/components/select/select.component.ts @@ -224,6 +224,15 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon // // https://github.com/shoelace-style/shoelace/issues/1763 // + document.addEventListener('focusin', this.handleDocumentFocusIn); + document.addEventListener('keydown', this.handleDocumentKeyDown); + document.addEventListener('mousedown', this.handleDocumentMouseDown); + + // If the component is rendered in a shadow root, we need to attach the focusin listener there too + if (this.getRootNode() !== document) { + this.getRootNode().addEventListener('focusin', this.handleDocumentFocusIn); + } + if ('CloseWatcher' in window) { this.closeWatcher?.destroy(); this.closeWatcher = new CloseWatcher(); @@ -234,14 +243,6 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon } }; } - document.addEventListener('focusin', this.handleDocumentFocusIn); - document.addEventListener('keydown', this.handleDocumentKeyDown); - document.addEventListener('mousedown', this.handleDocumentMouseDown); - - // If the component is rendered in a shadow root, we need to attach the focusin listener there too - if (this.getRootNode() !== document) { - this.getRootNode().addEventListener('focusin', this.handleDocumentFocusIn); - } } private removeOpenListeners() {