@@ -21,6 +21,7 @@ export default function KernDropdown(props: KernDropdownProps) {
2121 const [ disabledOptions , setDisabledOptions ] = useState < boolean [ ] > ( [ ] ) ;
2222 const [ backgroundColors , setBackgroundColors ] = useState < string [ ] > ( [ ] ) ;
2323 const [ searchText , setSearchText ] = useState ( '' ) ;
24+ const [ searchIndexes , setSearchIndexes ] = useState < number [ ] > ( ) ;
2425 const [ isOpen , setIsOpen_ ] = useState ( false ) ;
2526 const [ selectedCheckboxes , setSelectedCheckboxes ] = useState < any [ ] > ( [ ] ) ;
2627 const [ position , setPosition ] = useState ( null ) ;
@@ -51,11 +52,15 @@ export default function KernDropdown(props: KernDropdownProps) {
5152 useEffect ( ( ) => {
5253 const prepareOptions = prepareDropdownOptionsToArray ( props . options , props . hasSearchBar , props . valuePropertyPath ) ;
5354 if ( props . hasSearchBar ) {
54- setDropdownCaptions ( setOptionsWithSearchBar ( prepareOptions , searchText ) ) ;
55+ const [ remaining , indexes ] = setOptionsWithSearchBar ( prepareOptions , searchText )
56+ setDropdownCaptions ( remaining ) ;
57+ setSearchIndexes ( indexes ) ;
5558 } else if ( props . hasCheckboxes ) {
5659 setOptionsWithCheckboxes ( prepareOptions ) ;
60+ setSearchIndexes ( null ) ;
5761 } else {
5862 setDropdownCaptions ( prepareOptions ) ;
63+ setSearchIndexes ( null ) ;
5964 }
6065 } , [ props . options , searchText , selectedCheckboxes , props . hasSearchBar , props . hasCheckboxes , props . selectedCheckboxes , props . hasSelectAll , props . valuePropertyPath ] ) ;
6166
@@ -167,10 +172,12 @@ export default function KernDropdown(props: KernDropdownProps) {
167172 return ;
168173 }
169174 if ( props . selectedOption ) {
170- props . selectedOption ( props . options [ index ] ) ;
171175 if ( props . hoverBoxList ) setHoverBoxPosition ( null ) ;
172176 if ( props . hasSearchBar ) {
173177 setSearchText ( option ) ;
178+ props . selectedOption ( props . options [ searchIndexes [ index ] ] ) ;
179+ } else {
180+ props . selectedOption ( props . options [ index ] ) ;
174181 }
175182 setIsOpen ( false ) ;
176183 }
0 commit comments