feat(ui): Focus first searched item in selects#117450
Open
nsdeschenes wants to merge 7 commits into
Open
Conversation
Make searchable compact selects mark the first visible enabled result as active while keeping focus in the search input. Selecting with Enter now accepts that active search result, and callers can disable the behavior with search.autoFocusFirstResult. Co-Authored-By: OpenAI Codex <noreply@example.com>
Add aria-activedescendant for the search input when it keeps DOM focus while an option is active. Clear the active descendant when real focus moves into the result list so visual and assistive focus stay in sync. Co-Authored-By: OpenAI Codex <noreply@openai.com>
Avoid auto-selecting stale search results when CompactSelect is configured for server-side filtering with filter: false. Keep active-result autofocus enabled for client-filtered search, while preserving an explicit autoFocusFirstResult override. Co-Authored-By: OpenAI Codex <noreply@openai.com>
Scroll virtualized lists to the search-focused option so aria-activedescendant always references a rendered element. This preserves keyboard and screen reader behavior after the user searches from a scrolled virtualized menu. Add a regression test for virtualized CompactSelect search focus. Co-Authored-By: OpenAI Codex <noreply@openai.com>
Stop exporting an internal helper that is only used within CompactSelect internals so knip does not report it as an unused public export. Co-Authored-By: OpenAI Codex <noreply@openai.com>
Contributor
Story previewsPreview the stories changed in this PR on the Vercel deployment: Preview deployment: https://sentry-plwowtwe1.sentry.dev |
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a53f9f9. Configure here.
Recompute the current first visible search result when Enter is pressed instead of reading the search-focused key from a later effect. This prevents Enter from selecting a stale option when the query changes and the previous active key remains visible. Add a regression test for Enter immediately after a search query update. Co-Authored-By: OpenAI Codex <noreply@openai.com>
Add comments explaining how CompactSelect coordinates virtual focus between the search input and registered option lists. Co-Authored-By: OpenAI Codex <noreply@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

This PR updates the compact select so that it will highlight the first item in the list when the user searches for an item in the list, reducing some friction.
As well, a new prop is added in to control this feature, so it can be disabled if needed.