Skip to content

Commit

Permalink
reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
claviska committed Feb 20, 2024
1 parent e9405d3 commit 07b13d4
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/components/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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() {
Expand Down

0 comments on commit 07b13d4

Please sign in to comment.