-
Notifications
You must be signed in to change notification settings - Fork 561
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
Combobox items get wrong keyboard navigation order after being reordered #840
Comments
Hey! Jumping in because I’ve had a similar issue, and found an odd fix to it. The following change: <ComboboxList>
{matches.map((match) => (
+ <div>
<ComboboxOption key={match} value={match} />
+ </div>
))}
</ComboboxList> appears to fix the keyboard navigation issues you see in the sandbox. I have no idea why that is, or whether the extra div is having a negative impact on accessibility, or if something other than a div would also fix this—but anyway, thought I’d share this here in the hopes it helps find a proper fix. |
Hi! I also found an alternative fix to this last night and forgot to mention it here. Thanks for the reminder! Mine looks like this: <ComboboxList>
{options.map((option, i) => (
<ComboboxOption key={`${i}-${option.value}`} value={option.value} />
))}
</ComboboxList> The trick is the use of the array index in the In my case, |
Hi, I got the same problem. I solved it by explicitly setting the internal index: <ComboboxList>
{options.map((option, i) => (
<ComboboxOption index={i} key={option.value} value={option.value} />
))}
</ComboboxList> |
This worked for me, thank you! |
Thank you @lukasvice. This worked for me. |
🐛 Bug report
Current Behavior
When combobox list items are reordered, their keyboard navigation order doesn't seem to change. So if you use arrow keys to traverse through the list after a reorder, it jumps around the list instead of to the next item.
Expected behavior
When I press down, only the next immediate option should be selected.
Reproducible example
Example of a list of countries that are re-ordered as you type:
https://codesandbox.io/s/beautiful-panka-8ow2p?file=/src/App.js
Suggested solution(s)
I'm not sure why it's happening, but I'm guessing it has something to do with
@reach/descendants
. It seems like it's the same problem as in #827, but the fix in the CR doesn't help in my case.Additional context
n/a
Your environment
The text was updated successfully, but these errors were encountered: