@@ -42,25 +42,21 @@ const useMenuOptions = (
4242 const hideSelectedOptionsOrDefault = isBoolean ( hideSelectedOptions ) ? hideSelectedOptions : isMulti ;
4343
4444 useEffect ( ( ) => {
45- const selectedHash = selectedOption . length ? new Set ( selectedOption . map ( ( x ) => x . value ) ) : null ;
46- const normalizedSearch = trimAndFormatFilterStr ( searchValue , filterIgnoreCase , filterIgnoreAccents ) ;
45+ const selectedValues = selectedOption . map ( ( x ) => x . value ) ;
46+ const matchVal = trimAndFormatFilterStr ( searchValue , filterIgnoreCase , filterIgnoreAccents ) ;
4747
4848 const isOptionFilterMatch = ( option : MenuOption ) : boolean => {
49- if ( ! normalizedSearch ) return true ;
50-
49+ if ( ! matchVal ) return true ;
5150 const filterVal = getFilterOptionStringRef ( option ) ;
52- const normalizedOptionLabel = trimAndFormatFilterStr ( filterVal , filterIgnoreCase , filterIgnoreAccents ) ;
53-
54- return isFilterMatchAny
55- ? normalizedOptionLabel . includes ( normalizedSearch )
56- : normalizedOptionLabel . substr ( 0 , normalizedSearch . length ) === normalizedSearch ;
51+ const filterValNrml = trimAndFormatFilterStr ( filterVal , filterIgnoreCase , filterIgnoreAccents ) ;
52+ return isFilterMatchAny ? filterValNrml . includes ( matchVal ) : filterValNrml . startsWith ( matchVal ) ;
5753 } ;
5854
5955 const parseMenuOption = ( data : OptionData ) : MenuOption | undefined => {
6056 const value = getOptionValue ( data ) ;
6157 const label = getOptionLabel ( data ) ;
6258 const isDisabled = getIsOptionDisabledRef ( data ) ;
63- const isSelected = selectedHash ?. has ( value ) ?? false ;
59+ const isSelected = selectedValues . includes ( value ) ;
6460 const menuOption : MenuOption = { data, value, label, isDisabled, isSelected } ;
6561
6662 if ( ! isOptionFilterMatch ( menuOption ) || ( hideSelectedOptionsOrDefault && isSelected ) ) {
0 commit comments