-
Notifications
You must be signed in to change notification settings - Fork 5
fix: search button keyboard shortcut visual feedback #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for sitesearch-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| useEffect(() => { | ||
| const handleKeyDown = (event: KeyboardEvent) => { | ||
| const isModifierPressed = | ||
| modifierKey === "cmd" | ||
| ? event.metaKey || event.ctrlKey | ||
| : event.getModifierState( | ||
| modifierKey.charAt(0).toUpperCase() + modifierKey.slice(1), | ||
| ); | ||
|
|
||
| if (isModifierPressed && event.key.toLowerCase() === key) { | ||
| if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") { | ||
| event.preventDefault(); | ||
| openModal(); | ||
| setIsModalOpen(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cmd/Ctrl+K opens every search modal on a page
This handler is now hard-coded to Cmd/Ctrl+K for every instance, and the same change was applied to the AskAI variant in this commit. Pages that render multiple search experiences at once (e.g., the docs homepage hosts both Search and SearchWithAskAI) will now register two identical global listeners, so pressing Cmd/Ctrl+K opens both modals simultaneously instead of one, unlike the previous distinct shortcuts. Please reintroduce per-instance shortcuts or a way to disable the hotkey when multiple experiences coexist.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True but we don't want to have much code and complexity only for this, plus usually people will have only one search bar on screen at a time.
Maybe add the possibility to NOT listen ?
Search Button: Enhanced keyboard shortcut visual feedback
Adds interactive visual feedback to search button keyboard shortcuts, showing pressed state for modifier and K keys.
Description