Skip to content

fix(dropdown-menu): focus the search when opened inside a dialog - #162

Merged
tmccoy14 merged 1 commit into
mainfrom
fix/dropdown-search-focus-in-dialog
Sep 24, 2026
Merged

tmccoy14 merged 1 commit into
mainfrom
fix/dropdown-search-focus-in-dialog

Conversation

@tmccoy14

Copy link
Copy Markdown
Contributor

What

A searchable DropdownMenu (and so FilterDropdown / RadioDropdown) opened inside a Dialog or Sheet left focus on the menu, not the search box. Typing still searched, but the visible focus and the screen reader announcement pointed at the menu.

Why

DropdownMenuSearch focuses itself on mount. That runs before the menu's focus scope pauses the dialog's focus trap, so the trap pulls focus back into the dialog, and Radix then focuses the menu itself. Outside a dialog there is no trap, so it worked.

DropdownMenuContent now hands focus to the search the first time the menu takes focus after opening. SelectContent already recovers the same way, so SelectSearch was unaffected.

Found while adopting 4.3.0 in Guardian Studio (the project picker in Manage Roles & Permissions).

Changes

  • dropdown-menu.tsx: onFocus recovery on first focus per open. The flag resets when the search is hidden again, which covers a reopen during the exit animation, when the content stays mounted.
  • New test: opening a searchable menu inside a Dialog focuses the search. It fails without the fix.
  • 4.3.1, with a CHANGELOG entry.

Verification

  • pnpm format:check, pnpm lint, pnpm test (38 passing), pnpm build.
  • In Studio, with this build in place: click-open, keyboard-open and a quick reopen inside the dialog all focus the search. The page-level filter specs (activity logs, evaluation logs) still pass.

🤖 Generated with Claude Code

The search input focused itself on mount, before the menu's focus scope
paused the dialog's focus trap, so the trap pulled focus back out and
Radix then focused the menu. The menu now hands focus to the search on
its first focus after opening. Bumps to 4.3.1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tmccoy14
tmccoy14 merged commit 36d06e0 into main Sep 24, 2026
1 check passed
@tmccoy14
tmccoy14 deleted the fix/dropdown-search-focus-in-dialog branch September 24, 2026 18:00
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.

1 participant