diff --git a/package.json b/package.json index b291105..645a006 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@travelopia/web-components", - "version": "0.5.7", + "version": "0.5.8", "description": "Accessible web components for the modern web", "files": [ "dist" diff --git a/src/multi-select/tp-multi-select-option.ts b/src/multi-select/tp-multi-select-option.ts index 9774758..eb2d66f 100644 --- a/src/multi-select/tp-multi-select-option.ts +++ b/src/multi-select/tp-multi-select-option.ts @@ -28,10 +28,16 @@ export class TPMultiSelectOptionElement extends HTMLElement { if ( 'yes' !== this.getAttribute( 'selected' ) ) { multiSelect?.select( value ); - multiSelect?.dispatchEvent( new CustomEvent( 'select', { bubbles: true } ) ); + multiSelect?.dispatchEvent( new CustomEvent( 'select', { + bubbles: true, + detail: { value }, + } ) ); } else { multiSelect?.unSelect( value ); - multiSelect?.dispatchEvent( new CustomEvent( 'unselect', { bubbles: true } ) ); + multiSelect?.dispatchEvent( new CustomEvent( 'unselect', { + bubbles: true, + detail: { value }, + } ) ); } multiSelect?.dispatchEvent( new CustomEvent( 'change', { bubbles: true } ) ); } diff --git a/src/multi-select/tp-multi-select-search.ts b/src/multi-select/tp-multi-select-search.ts index d829df3..aab9e31 100644 --- a/src/multi-select/tp-multi-select-search.ts +++ b/src/multi-select/tp-multi-select-search.ts @@ -67,7 +67,7 @@ export class TPMultiSelectSearchElement extends HTMLElement { let matchedOptionCount = 0; // Hide and show options based on search. options.forEach( ( option: TPMultiSelectOptionElement ): void => { - if ( option.getAttribute( 'value' )?.match( new RegExp( `.*${ search.value }.*` ) ) ) { + if ( option.getAttribute( 'label' )?.toLowerCase().match( new RegExp( `.*${ search.value.replace( /\s/g, '.*' ) }.*` ) ) ) { option.removeAttribute( 'hidden' ); matchedOptionCount++; } else {