Skip to content

Commit 7430ca4

Browse files
Merge pull request #48 from Travelopia/fix/multi-select-event-conflict
Fix Multi Select Event Conflict
2 parents 287086c + c89de9a commit 7430ca4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/multi-select/tp-multi-select-search.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,15 @@ export class TPMultiSelectSearchElement extends HTMLElement {
9292
* @param {Event} e Click event.
9393
*/
9494
protected handleClick( e: Event ): void {
95+
// First, prevent propagation to avoid document.click set on `tp-multi-select`.
9596
e.preventDefault();
9697
e.stopPropagation();
98+
99+
// Now send the event so other stuff can work as per normal, and another event for good measure.
100+
this.dispatchEvent( new CustomEvent( 'multi-select-opened' ) );
101+
document.dispatchEvent( new Event( 'click' ) );
102+
103+
// Open multi select.
97104
this.closest( 'tp-multi-select' )?.setAttribute( 'open', 'yes' );
98105
}
99106

0 commit comments

Comments
 (0)