Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(combobox): when backspacing searchTerm highlight the first available option #1009

Conversation

gasparrobi
Copy link
Contributor

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

after the change:
combobox-after

@gasparrobi gasparrobi force-pushed the fix/combobox-highlight-on-search-term-change branch from 61a1e1e to 3ba371f Compare June 19, 2024 10:23
Copy link
Member

@zernonia zernonia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@zernonia zernonia merged commit 1742575 into radix-vue:main Jun 24, 2024
5 checks passed
@@ -211,10 +211,10 @@ watch(stringifiedModelValue, async () => {
immediate: !props.searchTerm,
})

watch(() => filteredOptions.value.length, async (length) => {
watch(() => [filteredOptions.value.length, searchTerm.value.length], async ([length, searchTermLength], [oldLength, oldSearchTermLength]) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If searchTerm.value is null/undefined this causes a .length error and bugs out the Combobox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants