feat(select): improve keyboard navigation in single select#1724
feat(select): improve keyboard navigation in single select#1724EdsonNhancale wants to merge 2 commits intodhis2:masterfrom
Conversation
- Add focus method to Input component for programmatic focus control - Add tabIndex and onKeyDown to OptionsList to enable keyboard navigation on the listbox - Forward ref to Filter component to allow focusing the filter input - When ArrowUp is pressed on the first option, focus moves to the filter input - When ArrowDown is pressed in filter input, focus moves to the listbox - This improves accessibility and user experience for keyboard-only users
|
kabaros
left a comment
There was a problem hiding this comment.
thanks for this @EdsonNhancale - it's much more complicated than I anticipated. Some comments here .. let me know if anything doesn't make sense.
| onFilterChange, | ||
| onFilterInputKeyDown, | ||
| filterRef, | ||
| onOptionsKeyDown, |
There was a problem hiding this comment.
is this onOptionsKeyDown used at all - I removed it all the way down, and everything seems to work as it is (since the hook has the reference to filter and controls focus)
| } | ||
|
|
||
| focus() { | ||
| this.inputRef.current.focus() |
There was a problem hiding this comment.
just in case, make this a bit more defensive this.inputRef.current?.focus?.()
| <div | ||
| ref={ref} | ||
| role="listbox" | ||
| tabIndex="-1" |
There was a problem hiding this comment.
I don't think this is necessary? actually when we don't add it, we get the nice effect that we can continue typing while going up and down the list




Implements LIBS-812
Description
Enhanced keyboard accessibility for the single select component. Added focus control to the Input, forwarded ref to Filter, and enabled keyboard navigation in OptionsList. Pressing ArrowUp from the first option moves focus to the filter, and ArrowDown from the filter moves focus to the list, improving usability for keyboard-only users.
Known issues
Checklist
All points above should be relevant for feature PRs. For bugfixes, some points might not be relevant. In that case, just check them anyway to signal the work is done.
Screenshots