Skip to content

🎨 Palette: [UX improvement] Add keyboard shortcut to focus search input - #266

Open
mkk2026 wants to merge 1 commit into
masterfrom
palette/search-keyboard-shortcut-15375496995824822650
Open

🎨 Palette: [UX improvement] Add keyboard shortcut to focus search input#266
mkk2026 wants to merge 1 commit into
masterfrom
palette/search-keyboard-shortcut-15375496995824822650

Conversation

@mkk2026

@mkk2026 mkk2026 commented May 2, 2026

Copy link
Copy Markdown
Owner

💡 What:
Added a dynamic keyboard shortcut (Cmd+K on Mac, Ctrl+K on Windows/Linux) to quickly focus the main search input on the dashboard. Also added a visual <kbd> hint that appears when the input is empty to educate users about the shortcut.

🎯 Why:
Searching is one of the primary actions on the dashboard. Requiring users to move their mouse to click the search bar creates friction. Adding a standard keyboard shortcut significantly speeds up the workflow for power users.

📸 Before/After:

  • Before: Users had to manually click the search input. Screen readers had no shortcut announced.
  • After: Users can press Cmd/Ctrl+K to instantly focus the search field. A small visual hint (⌘K or CtrlK) guides them when the input is empty.

♿ Accessibility:

  • Added the aria-keyshortcuts attribute dynamically depending on the user's OS (Meta+K vs Control+K) to ensure screen readers correctly announce the exact shortcut string expected by the Web Content Accessibility Guidelines.
  • Avoided Next.js hydration errors by initializing the OS state on the client side using a useEffect hook.

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

Summary by CodeRabbit

  • New Features
    • Introduced keyboard shortcut support to quickly focus the search input (Ctrl+K on Windows/Linux, Cmd+K on macOS)
    • Added visual keyboard shortcut hints displayed alongside the search input
    • Improved accessibility with proper keyboard shortcut metadata and labeling

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.

@coderabbitai

coderabbitai Bot commented May 2, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds keyboard shortcut accessibility to the security dashboard's search input. A journal entry documents the pattern for dynamic aria-keyshortcuts based on OS modifier detection. The implementation uses React state to detect the OS modifier (Meta vs Control), registers a global keydown listener for (Ctrl|Meta)+K to focus the search input, and displays the appropriate shortcut hint with aria-keyshortcuts and visual <kbd> elements.

Changes

Keyboard Shortcut Accessibility for Search Input

Layer / File(s) Summary
Documentation
.Jules/palette.md
Journal entry dated 2026-10-27 documents the pattern: detect OS modifier client-side post-mount to set aria-keyshortcuts and <kbd> hints dynamically, avoiding SSR hydration mismatches.
State & Event Handling
src/app/page.tsx (lines 3, 56–121)
React imports useRef hook. Component initializes modifierKey state (determined by navigator.platform) and searchInputRef, then registers/unregisters a window keydown handler to focus the input when `(Ctrl
UI Integration
src/app/page.tsx (lines 368–382)
Search Input attaches the ref, sets aria-keyshortcuts to the computed modifier key, and renders a conditional <kbd> element displaying the shortcut hint when the search query is empty.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A shortcut springs to life today,
Meta-K or Ctrl shows the way,
The search input leaps into view,
With aria-hints both fresh and true! ⌨️✨

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a keyboard shortcut (Cmd/Ctrl+K) to focus the search input as a UX improvement, which matches the changeset modifications across both the palette journal and the page component.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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-keyboard-shortcut-15375496995824822650

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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: 6466a9d474

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

// Keyboard shortcut handler
const handleKeyDown = (e: KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === '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 Restrict Mac shortcut handling to Meta+K

The keydown guard currently triggers on e.ctrlKey || e.metaKey, so on macOS both Ctrl+K and Cmd+K focus the search box even though the UI hint and aria-keyshortcuts advertise only Meta+K. This creates a behavior/accessibility mismatch and also suppresses native Ctrl+K text-editing behavior in focused inputs because preventDefault() runs whenever Control is held.

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: 1

🤖 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:
- Line 27: The journal heading "## 2026-10-27 - Dynamic Keyboard Shortcut
Accessibility" uses a future date; update that header in .Jules/palette.md to a
non-future date (e.g., the PR creation date "2026-05-02" or another past date
that accurately reflects when the entry was written) so repository history
remains chronological; edit the string in the header line to replace
"2026-10-27" with the chosen past date while leaving the rest of the heading
text unchanged.
🪄 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: 513d3611-4447-4d5d-9f76-611cd6b750e9

📥 Commits

Reviewing files that changed from the base of the PR and between 558fb10 and 6466a9d.

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

Comment thread .Jules/palette.md
**Learning:** Search inputs without a quick reset mechanism force users to manually delete text, which is tedious on mobile.
**Action:** Always include a conditional "Clear" button (X icon) inside the input wrapper when text is present, ensuring `aria-label` is set for screen readers.

## 2026-10-27 - Dynamic Keyboard Shortcut Accessibility

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 | ⚡ Quick win

Use a non-future date for this journal entry.

Line 27 is dated 2026-10-27, but this PR was created on May 2, 2026. That makes the timeline confusing in repository history.

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

In @.Jules/palette.md at line 27, The journal heading "## 2026-10-27 - Dynamic
Keyboard Shortcut Accessibility" uses a future date; update that header in
.Jules/palette.md to a non-future date (e.g., the PR creation date "2026-05-02"
or another past date that accurately reflects when the entry was written) so
repository history remains chronological; edit the string in the header line to
replace "2026-10-27" with the chosen past date while leaving the rest of the
heading text unchanged.

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