Skip to content

Commit b16c7fd

Browse files
Merge pull request #50 from Travelopia/fix/firefox-multi-select-pill
Fix: Multi-Select Cross Browser Pill Remove
2 parents 6b07b80 + e80b3cb commit b16c7fd

File tree

6 files changed

+11
-17
lines changed

6 files changed

+11
-17
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@travelopia/web-components",
3-
"version": "0.5.19",
3+
"version": "0.5.21",
44
"description": "Accessible web components for the modern web",
55
"files": [
66
"dist"

src/multi-select/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
<tp-multi-select-field>
9494
<tp-multi-select-pills></tp-multi-select-pills>
9595
<tp-multi-select-search>
96-
<input placeholder="Select...">
96+
<input type="text" placeholder="Select...">
9797
</tp-multi-select-search>
9898
</tp-multi-select-field>
9999
<tp-multi-select-options>

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,12 @@ export class TPMultiSelectPillElement extends HTMLElement {
1616
/**
1717
* Handle button click.
1818
*
19-
* @param {any} e Click event.
19+
* @param {Event} e Click event.
2020
*/
21-
handleButtonClick( e: any | null ): void {
21+
handleButtonClick( e: Event | null ): void {
2222
e?.preventDefault();
2323
e?.stopPropagation();
24-
25-
/**
26-
* If the event is has a pointerType, which means it's a mouse event or touch event
27-
* Only then we remove pill.
28-
* This will ensure, it will not get fired when a enter button is pressed.
29-
* We do this so that it does not remove the pills when enter button is pressed.
30-
*/
31-
if ( e?.pointerType ) {
32-
this.removePill();
33-
}
24+
this.removePill();
3425
}
3526

3627
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class TPMultiSelectPillsElement extends HTMLElement {
6767
newPill.setAttribute( 'value', pillValue );
6868
newPill.innerHTML = `
6969
<span>${ multiSelectOption.getAttribute( 'label' ) ?? '' }</span>
70-
<button>x</button>
70+
<button type="button">x</button>
7171
`;
7272
this.appendChild( newPill );
7373
} );

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export class TPMultiSelectSearchElement extends HTMLElement {
3838
}
3939

4040
switch ( e.key ) {
41+
case 'Enter':
42+
e.preventDefault(); // Prevent inadvertent form submits.
43+
break;
4144
case 'ArrowDown':
4245
multiSelect.setAttribute( 'open', 'yes' );
4346
break;

0 commit comments

Comments
 (0)