Skip to content

Commit 359459e

Browse files
Merge pull request #38 from Travelopia/fix/multi-select-search
Fix the search and selection issue
2 parents 61d812a + 8a28474 commit 359459e

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

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.16",
3+
"version": "0.5.17",
44
"description": "Accessible web components for the modern web",
55
"files": [
66
"dist"

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ export class TPMultiSelectPillsElement extends HTMLElement {
1313
* Connected callback.
1414
*/
1515
connectedCallback(): void {
16+
// Events.
1617
this.closest( 'tp-multi-select' )?.addEventListener( 'change', this.update.bind( this ) );
18+
this.closest( 'tp-multi-select' )?.querySelector( 'select' )?.addEventListener( 'change', ( () => this.update() ) as EventListener );
19+
20+
// Update.
1721
this.update();
1822
}
1923

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class TPMultiSelectSearchElement extends HTMLElement {
6767
let matchedOptionCount = 0;
6868
// Hide and show options based on search.
6969
options.forEach( ( option: TPMultiSelectOptionElement ): void => {
70-
if ( option.getAttribute( 'label' )?.toLowerCase().match( new RegExp( `.*${ search.value.replace( /\s/g, '.*' ) }.*` ) ) ) {
70+
if ( option.getAttribute( 'label' )?.toLowerCase().match( new RegExp( `.*${ search.value.toLowerCase().replace( /\s/g, '.*' ) }.*` ) ) ) {
7171
option.removeAttribute( 'hidden' );
7272
matchedOptionCount++;
7373
} else {

0 commit comments

Comments
 (0)