diff --git a/package-lock.json b/package-lock.json index 9a714b0..4ca1833 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@travelopia/web-components", - "version": "0.5.19", + "version": "0.5.21", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@travelopia/web-components", - "version": "0.5.19", + "version": "0.5.21", "license": "MIT", "devDependencies": { "@wordpress/eslint-plugin": "^17.1.0", diff --git a/package.json b/package.json index 0816f98..390b39b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@travelopia/web-components", - "version": "0.5.19", + "version": "0.5.21", "description": "Accessible web components for the modern web", "files": [ "dist" diff --git a/src/multi-select/index.html b/src/multi-select/index.html index db3490a..1c642d0 100644 --- a/src/multi-select/index.html +++ b/src/multi-select/index.html @@ -93,7 +93,7 @@ - + diff --git a/src/multi-select/tp-multi-select-pill.ts b/src/multi-select/tp-multi-select-pill.ts index 352d002..6c98035 100644 --- a/src/multi-select/tp-multi-select-pill.ts +++ b/src/multi-select/tp-multi-select-pill.ts @@ -16,21 +16,12 @@ export class TPMultiSelectPillElement extends HTMLElement { /** * Handle button click. * - * @param {any} e Click event. + * @param {Event} e Click event. */ - handleButtonClick( e: any | null ): void { + handleButtonClick( e: Event | null ): void { e?.preventDefault(); e?.stopPropagation(); - - /** - * 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(); - } + this.removePill(); } /** diff --git a/src/multi-select/tp-multi-select-pills.ts b/src/multi-select/tp-multi-select-pills.ts index de58910..1bc9b99 100644 --- a/src/multi-select/tp-multi-select-pills.ts +++ b/src/multi-select/tp-multi-select-pills.ts @@ -67,7 +67,7 @@ export class TPMultiSelectPillsElement extends HTMLElement { newPill.setAttribute( 'value', pillValue ); newPill.innerHTML = ` ${ multiSelectOption.getAttribute( 'label' ) ?? '' } - + `; this.appendChild( newPill ); } ); diff --git a/src/multi-select/tp-multi-select-search.ts b/src/multi-select/tp-multi-select-search.ts index 712ee2b..08919dc 100644 --- a/src/multi-select/tp-multi-select-search.ts +++ b/src/multi-select/tp-multi-select-search.ts @@ -38,6 +38,9 @@ export class TPMultiSelectSearchElement extends HTMLElement { } switch ( e.key ) { + case 'Enter': + e.preventDefault(); // Prevent inadvertent form submits. + break; case 'ArrowDown': multiSelect.setAttribute( 'open', 'yes' ); break;