kopia lustrzana https://github.com/shoelace-style/shoelace
Fixes #135 - uses the composedPath() array to find the closest matching elements the event was triggered on (#136)
composedPath() is preferred over closest() since it pierces shadow DOM boundariespull/146/head
rodzic
81816fba56
commit
0328854285
|
@ -217,10 +217,9 @@ export class Dropdown {
|
|||
}
|
||||
|
||||
handleDocumentMouseDown(event: MouseEvent) {
|
||||
const target = event.target as HTMLElement;
|
||||
|
||||
// Close when clicking outside of the close element
|
||||
if (target.closest(this.containingElement.tagName.toLowerCase()) !== this.containingElement) {
|
||||
const path = event.composedPath() as Array<EventTarget>;
|
||||
if (!path.includes(this.containingElement)) {
|
||||
this.hide();
|
||||
return;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue