From 4b175bca9e3fd7206bb4b2ff54cf43433097e1d7 Mon Sep 17 00:00:00 2001 From: Imran Sayed Date: Thu, 22 Feb 2024 15:50:16 -0600 Subject: [PATCH 1/2] Update JS' --- package.json | 2 +- src/multi-select/tp-multi-select-pill.ts | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index af74faf..e474e87 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@travelopia/web-components", - "version": "0.5.17", + "version": "0.5.18", "description": "Accessible web components for the modern web", "files": [ "dist" diff --git a/src/multi-select/tp-multi-select-pill.ts b/src/multi-select/tp-multi-select-pill.ts index 7277ae8..1ca1e7b 100644 --- a/src/multi-select/tp-multi-select-pill.ts +++ b/src/multi-select/tp-multi-select-pill.ts @@ -11,18 +11,26 @@ export class TPMultiSelectPillElement extends HTMLElement { * Connected callback. */ connectedCallback(): void { - this.querySelector( 'button' )?.addEventListener( 'click', this.handleButtonClick.bind( this ) ); + this.querySelector( 'button' )?.addEventListener( 'click', ( event: any ) => this.handleButtonClick( event ) ); } - /** * Handle button click. * - * @param {Event} e Click event. + * @param {any} e Click event. */ - handleButtonClick( e: Event | null ): void { + handleButtonClick( e: any | null ): void { e?.preventDefault(); e?.stopPropagation(); - this.removePill(); + + /** + * If the event is has a pointerType, which means it's a mouse event or touch event + * Only then we remove pill. + * This will ensure, it will not get fired when a enter button is pressed. + * We do this so that it does not remove the pills when enter button is pressed. + */ + if ( e?.pointerType ) { + this.removePill(); + } } /** From 24d49f855f7d8eb3b35ab6f1acf88bcfc7b96b05 Mon Sep 17 00:00:00 2001 From: Imran Sayed Date: Thu, 22 Feb 2024 15:58:42 -0600 Subject: [PATCH 2/2] Update JS --- src/multi-select/tp-multi-select-pill.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/multi-select/tp-multi-select-pill.ts b/src/multi-select/tp-multi-select-pill.ts index 1ca1e7b..352d002 100644 --- a/src/multi-select/tp-multi-select-pill.ts +++ b/src/multi-select/tp-multi-select-pill.ts @@ -11,7 +11,7 @@ export class TPMultiSelectPillElement extends HTMLElement { * Connected callback. */ connectedCallback(): void { - this.querySelector( 'button' )?.addEventListener( 'click', ( event: any ) => this.handleButtonClick( event ) ); + this.querySelector( 'button' )?.addEventListener( 'click', this.handleButtonClick.bind( this ) ); } /** * Handle button click.