Skip to content

🎨 Palette: Add Cmd/Ctrl+K shortcut for search input - #162

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

🎨 Palette: Add Cmd/Ctrl+K shortcut for search input#162
mkk2026 wants to merge 1 commit into
masterfrom
palette-search-shortcut-7158290000471400712

Conversation

@mkk2026

@mkk2026 mkk2026 commented Mar 27, 2026

Copy link
Copy Markdown
Owner

💡 What:
Added a Cmd+K (Mac) or Ctrl+K (Windows/Linux) keyboard shortcut to quickly focus the global search input on the Security Dashboard.

🎯 Why:
For power users and keyboard-heavy workflows, reaching for the mouse to click the search bar is a source of friction. Adding a standard Cmd/Ctrl+K shortcut significantly speeds up interaction.

📸 Before/After:
Before: Search input was plain text, requiring a manual click to focus.
After: Search input displays a subtle, OS-aware <kbd> hint (e.g., ⌘K) when empty. Pressing the shortcut instantly focuses the input. Clearing the input also smartly returns focus to the search bar.

♿ Accessibility:

  • Added a dynamic aria-keyshortcuts attribute to the input element so screen readers can announce the shortcut.
  • The OS-detection logic is wrapped in an isMounted effect to prevent React Server-Side Rendering (SSR) hydration mismatch errors.
  • Ensure focus is returned to the input after the 'clear search' button is clicked.

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

Summary by CodeRabbit

Release Notes

  • New Features
    • Added keyboard shortcut support (Ctrl+K on Windows/Linux, Cmd+K on Mac) to quickly focus the search input
    • Search bar displays the appropriate keyboard shortcut hint when empty
    • Improved search clearing behavior to refocus the input field after clearing

Adds a Cmd+K / Ctrl+K keyboard shortcut to focus the global search input on the main dashboard. Includes a visual <kbd> hint that dynamically updates based on the user's OS, ensuring keyboard accessibility via `aria-keyshortcuts`. Also automatically refocuses the input when the 'clear' button is clicked.

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

vercel Bot commented Mar 27, 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 Mar 27, 2026 0:25am

@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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Mar 27, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Added keyboard shortcut support (Ctrl+K / Meta+K) to focus the search input with platform detection, global keydown listener, visual kbd hint, and improved search-clear button behavior including accessibility attributes.

Changes

Cohort / File(s) Summary
Search Input Keyboard Shortcut Enhancement
src/app/page.tsx
Added useRef for input reference, isMac and isMounted state flags, and useEffect hook to detect platform and register global keydown listener for Ctrl+K / Meta+K shortcuts. Updated Input with ref and dynamic aria-keyshortcuts attribute. Added conditional visual kbd hint for empty search state. Modified search-clear button to refocus input after clearing with updated styling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 With Ctrl+K and Meta so bright,
The search input springs into sight,
Platform-aware, Mac or PC,
Keyboard magic flows so free,
Focus shifts with shortcuts gleam,
Accessibility's the dream! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a Cmd/Ctrl+K keyboard shortcut for the search input functionality.

✏️ 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-7158290000471400712

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.

@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.

🧹 Nitpick comments (1)
src/app/page.tsx (1)

64-69: Consider guarding against shortcut conflicts in editable fields.

The global keydown handler will intercept Ctrl+K/Cmd+K even when the user is typing in other input fields or text areas. This is a common pattern for global search shortcuts (used by GitHub, Slack, etc.), but if there are other editable fields on the page where Ctrl+K might have meaning (e.g., creating hyperlinks in rich text editors), consider adding a guard:

♻️ Optional guard for editable contexts
     const handleKeyDown = (e: KeyboardEvent) => {
+      // Skip if user is in a contenteditable or non-search input
+      const target = e.target as HTMLElement
+      if (target.isContentEditable) return
+
       if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') {
         e.preventDefault()
         searchInputRef.current?.focus()
       }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/page.tsx` around lines 64 - 69, The global keyboard handler
handleKeyDown currently focuses searchInputRef on Ctrl/Cmd+K even when the user
is inside other editable elements; update handleKeyDown to ignore the shortcut
when the event target is an input, textarea or an element with
contentEditable="true" (and optionally when composing) by early-returning in
those cases before calling searchInputRef.current?.focus(); reference the
handleKeyDown function and searchInputRef to locate and implement this guard.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/app/page.tsx`:
- Around line 64-69: The global keyboard handler handleKeyDown currently focuses
searchInputRef on Ctrl/Cmd+K even when the user is inside other editable
elements; update handleKeyDown to ignore the shortcut when the event target is
an input, textarea or an element with contentEditable="true" (and optionally
when composing) by early-returning in those cases before calling
searchInputRef.current?.focus(); reference the handleKeyDown function and
searchInputRef to locate and implement this guard.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 42d5a1cf-3017-4cdd-97e9-aa12b8e23129

📥 Commits

Reviewing files that changed from the base of the PR and between 558fb10 and 5c77cee.

📒 Files selected for processing (1)
  • src/app/page.tsx

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