Skip to content

feat(select): improve keyboard navigation in single select#1724

Open
EdsonNhancale wants to merge 2 commits intodhis2:masterfrom
EdsonNhancale:LIBS-812/keyboard-accessible
Open

feat(select): improve keyboard navigation in single select#1724
EdsonNhancale wants to merge 2 commits intodhis2:masterfrom
EdsonNhancale:LIBS-812/keyboard-accessible

Conversation

@EdsonNhancale
Copy link

  • 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

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

  • issue

Checklist

  • API docs are generated
  • Tests were added
  • Storybook demos were added

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

Simple single select - Made with Clipchamp (1)

- 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
@EdsonNhancale EdsonNhancale requested a review from a team as a code owner January 31, 2026 15:50
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
2 New issues
2 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Collaborator

@kabaros kabaros left a comment

Choose a reason for hiding this comment

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

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,
Copy link
Collaborator

Choose a reason for hiding this comment

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

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()
Copy link
Collaborator

Choose a reason for hiding this comment

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

just in case, make this a bit more defensive this.inputRef.current?.focus?.()

<div
ref={ref}
role="listbox"
tabIndex="-1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

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.

2 participants