fix(combobox): when backspacing searchTerm highlight the first available option #1009
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think current highlighting functionality is unintuitive.
When the user is removing characters (eg: by backspacing) the highlighted option should always be the first matching option from the dropdown list. It should provide the same behavior as typing, but backwards.
for reference please check shadcn/ui's combobox or headleassui's combobox
this PR is fixing that behavior.
before:
![combobox-before](https://private-user-images.githubusercontent.com/15650871/341023000-58f2e36e-0d62-43c5-b147-2af0f0af55cf.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI1OTIxMjQsIm5iZiI6MTcyMjU5MTgyNCwicGF0aCI6Ii8xNTY1MDg3MS8zNDEwMjMwMDAtNThmMmUzNmUtMGQ2Mi00M2M1LWIxNDctMmFmMGYwYWY1NWNmLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODAyVDA5NDM0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJhODZmNjVjNDcyNGEyYjU0NTdmM2Y3ZjJjNWQ5OTA0ZjI2ZmY3YTkxZDA1OWY3N2MzNGY1YTNiYWVjYzhiODkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.zEnrNS3E7Nilor-6fw5-VyCy_H_--H37K6BMkjQ8504)
after the change:
![combobox-after](https://private-user-images.githubusercontent.com/15650871/341023116-fcffa122-0da6-45d0-bfa3-f6a0db171e52.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI1OTIxMjQsIm5iZiI6MTcyMjU5MTgyNCwicGF0aCI6Ii8xNTY1MDg3MS8zNDEwMjMxMTYtZmNmZmExMjItMGRhNi00NWQwLWJmYTMtZjZhMGRiMTcxZTUyLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODAyVDA5NDM0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJjNDZmYjFkNDUwZTQyY2Q3NDIwZjdhMDA4MTBhZTM5MjQ0NGVhOTI5NmM2ZDZkMmNiM2M3NzdhOWE0MjUxMjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Up9qW4pw-063vH-At37_bLb3j8f4_IcV4YMKmFnGOI0)