fix: prevent Cmd+K from opening duplicate search dialogs#158
Conversation
The Search component bundled trigger, dialog, and the Cmd+K keydown listener together. The default theme mounts it twice (mobile header and sidebar header), so each keypress opened two stacked dialogs. Split it into SearchProvider (shared open state), Search (trigger-only button), and SearchDialog (single dialog + single keydown listener). The provider and dialog are mounted once in App, so themes only render trigger buttons. Paper theme's hidden-trigger workaround is removed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughSearch dialog state is refactored from local component state into a shared React context via a new ChangesSearch UI context refactor
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
Pressing Cmd/Ctrl+K opened two stacked search dialogs in the default theme.
The
Searchcomponent bundled the trigger button, theCommand.Dialog, and the Cmd+K keydown listener in one component. The default theme mounts<Search />twice (mobile header + sidebar header), so each instance registered its own listener and opened its own dialog.Fix
Split
search.tsxinto three parts:SearchProvider— small context holding the sharedopenstateSearch— trigger-only icon button, opens the dialog via contextSearchDialog— the singleCommand.Dialogwith the single Cmd+K listener and query logicSearchProvider+SearchDialogare mounted once inApp.tsx(gated byconfig.search?.enabled), so themes only render trigger buttons wherever they want. The paper theme's hidden-trigger workaround (display: nonetrigger just to host the dialog) is removed.Verification
Headless Chrome against the dev server, both themes:
🤖 Generated with Claude Code