Skip to content

🎨 Palette: [UX improvement] Add keyboard shortcut for global search - #210

Open
mkk2026 wants to merge 1 commit into
masterfrom
palette-search-shortcut-15643281697570949716
Open

🎨 Palette: [UX improvement] Add keyboard shortcut for global search#210
mkk2026 wants to merge 1 commit into
masterfrom
palette-search-shortcut-15643281697570949716

Conversation

@mkk2026

@mkk2026 mkk2026 commented Apr 13, 2026

Copy link
Copy Markdown
Owner

💡 What: Added a Cmd+K (Mac) or Ctrl+K (Windows/Linux) keyboard shortcut to focus the global search input. A visual hint (⌘K or Ctrl K) is also displayed inside the input field.
🎯 Why: To improve keyboard navigation and usability for power users.
📸 Before/After: The search input now displays a keyboard shortcut hint on the right side.
Accessibility: Added aria-keyshortcuts to dynamically announce the correct shortcut to screen readers based on the OS. Evaluates the modifier client-side using isMounted to prevent SSR hydration errors.


PR created automatically by Jules for task 15643281697570949716 started by @corebrimtech

Summary by CodeRabbit

  • New Features
    • Added global keyboard shortcut to focus search: use Cmd+K (Mac) or Ctrl+K (Windows/Linux) to quickly access search from anywhere in the application
    • Enhanced search accessibility with improved screen reader support and a visible keyboard shortcut hint for users

Added `Cmd+K` / `Ctrl+K` keyboard shortcut to focus the global search input on the dashboard. This enhancement significantly improves keyboard navigation. It correctly uses the `isMounted` pattern to display the OS-specific modifier key hint without causing SSR hydration mismatches, and dynamically sets the `aria-keyshortcuts` attribute to announce the shortcut correctly to screen readers.

Co-authored-by: corebrimtech <175357468+corebrimtech@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Apr 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
security-news-scraper Ready Ready Preview, Comment Apr 13, 2026 0:39am

@coderabbitai

coderabbitai Bot commented Apr 13, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds keyboard shortcut support (Cmd+K/Ctrl+K) to focus the search input on the security dashboard. Implementation includes an isMounted state flag to prevent SSR hydration mismatches, platform detection for displaying the correct modifier key, and dynamic aria-keyshortcuts attributes for improved screen reader accessibility.

Changes

Cohort / File(s) Summary
Documentation
.Jules/palette.md
Added journal entry documenting keyboard shortcut requirements for search input focusing and accessibility enhancements.
Search Input Keyboard Shortcut
src/app/page.tsx
Implemented Cmd/Ctrl+K keyboard listener with searchInputRef for input focus, isMounted flag to safely detect platform, conditional aria-keyshortcuts attribute, and visual <kbd> hint with platform-aware modifier key display.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A shortcut so swift, Cmd and K align,
Focus flows faster on search divine,
SSR-safe with isMounted's care,
Screen readers rejoice, shortcuts to spare! ⌨️✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references a keyboard shortcut feature for global search, which directly matches the core functionality implemented in the PR (Cmd+K/Ctrl+K shortcut). The emoji and category prefix add cosmetic noise but do not obscure the main change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch palette-search-shortcut-15643281697570949716

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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.

Reviewed commit: 908744f0b8

ℹ️ 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".

Comment thread src/app/page.tsx
Comment on lines +377 to +379
<div className="absolute right-14 top-1/2 -translate-y-1/2 pointer-events-none flex gap-1">
<kbd className="hidden sm:inline-flex h-5 items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100">
<span className="text-xs">{navigator.platform.includes('Mac') ? '⌘' : 'Ctrl'}</span>K

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reserve input space for the shortcut hint

The new <kbd> hint is absolutely positioned inside the search field, but the input still uses the old right padding, so typed text can render underneath the hint (and becomes more cramped when the clear button is also shown). This is visible on longer queries and makes the search value harder to read/edit; increase the input’s right padding or hide the hint when content is present.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.Jules/palette.md:
- Around line 26-28: The journal entry date "2026-10-27" in .Jules/palette.md is
inconsistent with this PR (created April 13, 2026); update that date to the
correct PR date (e.g., 2026-04-13) so the journal entry matches the PR timeline,
ensuring the header line beginning "## 2026-10-27 - Keyboard Shortcuts for
Search" is edited to the corrected date string.

In `@src/app/page.tsx`:
- Around line 63-74: The keydown handler currently treats Cmd and Ctrl
interchangeably; update the useEffect's handleKeyDown so it enforces the
platform-specific modifier: detect macOS (e.g., via navigator.platform or
navigator.userAgent includes "Mac") and require e.metaKey (and not e.ctrlKey)
for Mac, otherwise require e.ctrlKey (and not e.metaKey) for non‑Mac, then call
e.preventDefault() and focus searchInputRef.current?.focus() only when the
correct modifier + 'k' is pressed; keep the same event
registration/unregistration in useEffect.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 444d2019-64d5-45b5-92aa-51a52d7bc380

📥 Commits

Reviewing files that changed from the base of the PR and between 558fb10 and 908744f.

📒 Files selected for processing (2)
  • .Jules/palette.md
  • src/app/page.tsx

Comment thread .Jules/palette.md
Comment on lines +26 to +28
## 2026-10-27 - Keyboard Shortcuts for Search
**Learning:** Adding keyboard shortcuts (like Cmd+K or Ctrl+K) for primary search inputs significantly improves keyboard navigation. Using an `isMounted` state prevents hydration mismatches when conditionally rendering OS-specific modifiers based on `navigator.platform`. It's also important to dynamically set `aria-keyshortcuts` to improve screen reader context.
**Action:** Always implement a keyboard shortcut (Cmd+K/Ctrl+K) for global search inputs and use the `isMounted` pattern for OS detection to ensure SSR compatibility.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Journal date appears inconsistent with this PR timeline.

Line [26] says 2026-10-27, but this PR was created on April 13, 2026. If this entry documents this PR’s work, the date should be corrected to avoid timeline confusion.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.Jules/palette.md around lines 26 - 28, The journal entry date "2026-10-27"
in .Jules/palette.md is inconsistent with this PR (created April 13, 2026);
update that date to the correct PR date (e.g., 2026-04-13) so the journal entry
matches the PR timeline, ensuring the header line beginning "## 2026-10-27 -
Keyboard Shortcuts for Search" is edited to the corrected date string.

Comment thread src/app/page.tsx
Comment on lines +63 to +74
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
// Check for Cmd+K (Mac) or Ctrl+K (Windows/Linux)
if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
e.preventDefault()
searchInputRef.current?.focus()
}
}

window.addEventListener('keydown', handleKeyDown)
return () => window.removeEventListener('keydown', handleKeyDown)
}, [])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Shortcut behavior doesn’t match the platform-specific hint/ARIA contract.

Line [66] currently allows Cmd+K or Ctrl+K on all platforms, but Line [370] and Line [379] advertise only one modifier per OS. On macOS, this means Ctrl+K is unintentionally captured too.

🔧 Suggested fix
 useEffect(() => {
+  const isMac = navigator.platform.includes('Mac')
+
   const handleKeyDown = (e: KeyboardEvent) => {
-    // Check for Cmd+K (Mac) or Ctrl+K (Windows/Linux)
-    if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
+    const matchesModifier = isMac
+      ? e.metaKey && !e.ctrlKey
+      : e.ctrlKey && !e.metaKey
+
+    if (matchesModifier && e.key.toLowerCase() === 'k') {
       e.preventDefault()
       searchInputRef.current?.focus()
     }
   }

Also applies to: 370-379

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/page.tsx` around lines 63 - 74, The keydown handler currently treats
Cmd and Ctrl interchangeably; update the useEffect's handleKeyDown so it
enforces the platform-specific modifier: detect macOS (e.g., via
navigator.platform or navigator.userAgent includes "Mac") and require e.metaKey
(and not e.ctrlKey) for Mac, otherwise require e.ctrlKey (and not e.metaKey) for
non‑Mac, then call e.preventDefault() and focus searchInputRef.current?.focus()
only when the correct modifier + 'k' is pressed; keep the same event
registration/unregistration in useEffect.

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