fix(search): open cmd+K with the cursor in the search box - #833
Merged
Merged
Conversation
The dialog's first focusable element is the Conversations tab button, so that is where Radix put focus when the dialog opened: typing right after cmd+K went nowhere until the search box was clicked. Clicking a tab moved focus onto the tab as well. The search box now takes focus when the dialog opens and keeps it when switching tabs (the tab buttons no longer take focus on mouse down).
`autoFocus` focused the search box while the dialog was still mounting, before Radix's focus trap started listening, so the trap never recorded it and had nothing to pull focus back to. The chat composer refocuses itself when an agent turn ends; with the dialog open over it, the rest of the query was typed into the composer, where Enter sends it to the agent. Focus the box from the dialog's open auto-focus instead (CommandDialog now forwards onOpenAutoFocus), which runs once the trap is listening. The agent filter chips now keep the cursor in the box on mouse down, as the tabs do, so picking a filter doesn't stop typing from searching.
Owner
|
codeg work task |
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.
Summary
The cmd+K search dialog now opens with the cursor in its search box, and keeps it there when switching between the Conversations and Files tabs.
Cause
The dialog's first focusable element is the Conversations tab button, so that is where Radix's open auto-focus landed. Typing right after cmd+K went nowhere until the search box was clicked, and clicking a tab moved focus onto the tab.
Changes
CommandInputtakes focus when the dialog opens (autoFocus).Verification
search-command-dialog.test.tsx(2 tests): fails on main (focus sits on the tab button and typed text never reaches the input), passes with this change.