Skip to content

🎨 Palette: Keyboard Shortcut for Search Discoverability - #307

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

🎨 Palette: Keyboard Shortcut for Search Discoverability#307
mkk2026 wants to merge 1 commit into
masterfrom
palette/keyboard-shortcut-search-3979666548622218178

Conversation

@mkk2026

@mkk2026 mkk2026 commented May 17, 2026

Copy link
Copy Markdown
Owner

What: Added a global keyboard shortcut (Ctrl+K / Cmd+K) to focus the main search input on the Security Dashboard. Included a visual <kbd> hint inside the input box that adapts to the user's operating system (showing on Mac and Ctrl elsewhere).

Why: Search inputs without a quick keyboard shortcut force users to navigate away from the keyboard to use the mouse to click into the search field. This reduces efficiency, especially for power users scanning through the security dashboard.

Before/After:

  • Before: The search input was a standard text box requiring a mouse click to focus.
  • After: The search input now displays a sleek "Ctrl K" or "⌘ K" hint inside the right edge. Pressing this shortcut globally anywhere on the page instantly focuses the input. The layout intelligently shifts the shortcut hint when text is entered to avoid overlapping the clear ("X") button.

Accessibility: Added the aria-keyshortcuts attribute to the search <Input> so screen readers can properly announce the available shortcut (e.g., "Meta+K" or "Control+K"). Next.js hydration mismatches were avoided by executing the OS detection strictly on the client side after the component mounts.


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

Summary by CodeRabbit

  • New Features
    • Added global keyboard shortcut support: press Ctrl+K (Windows/Linux) or Cmd+K (macOS) to instantly focus the search bar from anywhere in the app.
    • Search input now displays platform-specific keyboard shortcut hints (⌘K on Mac, Ctrl+K elsewhere) to improve discoverability.

Review Change Stack

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 17, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

A global keyboard shortcut (Ctrl+K on Windows/Linux, Cmd+K on macOS) now focuses the main search input. The implementation detects client mount and platform, registers a keydown listener, and displays a platform-aware visual hint with SSR-safe conditional rendering.

Changes

Global Keyboard Shortcut for Search

Layer / File(s) Summary
Hook setup and keyboard listener
src/app/page.tsx, .Jules/palette.md
Adds useRef import; introduces mounted and isMac state with a useEffect to initialize on mount and detect macOS; registers a second useEffect that listens for Ctrl+K/Meta+K keydown and focuses the search input; documents the pattern in the keyboard shortcut discoverability journal entry.
Search input integration and visual hint
src/app/page.tsx
Attaches the search input ref, sets aria-keyshortcuts based on isMac, adjusts right padding to accommodate the shortcut hint, and conditionally renders a <kbd> visual hint "⌘/Ctrl K" only after mount to prevent SSR hydration mismatches.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • mkk2026/Security.News.Scraper#5: Both PRs modify src/app/page.tsx's search input accessibility props (adding/updating ARIA attributes—aria-keyshortcuts/mount-based shortcut hint in the main PR and aria-label in the retrieved PR).
  • mkk2026/Security.News.Scraper#46: Both PRs modify src/app/page.tsx's main search input UI/props—main PR updates the input for Ctrl/Cmd+K focus/ARIA and conditional shortcut hint, while the retrieved PR adds a clear (X) button and adjusts right-side padding to fit it.

Poem

A shortcut springs forth—⌘ and Ctrl unite,
The search field focuses with keyboard delight! 🐇✨
No hydration mismatch shall block this quest,
Platform-aware hints put the user's mind at rest.

🚥 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 references keyboard shortcut discoverability for search, which directly matches the main change: adding Ctrl+K/Cmd+K keyboard shortcut for search input focus.
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/keyboard-shortcut-search-3979666548622218178

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/app/page.tsx

Oops! Something went wrong! :(

ESLint: 9.39.4

ESLint couldn't find the plugin "eslint-plugin-react-hooks".

(The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react-hooks@latest --save-dev

The plugin "eslint-plugin-react-hooks" was referenced from the config file in " » eslint-config-next/core-web-vitals » /node_modules/.pnpm/eslint-config-next@15.3.5_eslint@9.39.4_typescript@5.9.3/node_modules/eslint-config-next/index.js".

If you still can't figure out the problem, please see https://eslint.org/docs/latest/use/troubleshooting.


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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/app/page.tsx`:
- Around line 65-74: The shortcut handler in useEffect (handleKeyDown) compares
e.key case-sensitively so it fails with Caps Lock on; update the condition to be
case-insensitive (e.g., compare e.key.toLowerCase() === 'k') or use the physical
key code (e.code === 'KeyK') to detect the K key regardless of Caps Lock, then
keep the existing e.preventDefault() and searchInputRef.current?.focus()
behavior.
🪄 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: f27fd30a-0a54-4e91-b79d-11536f2b022d

📥 Commits

Reviewing files that changed from the base of the PR and between 558fb10 and 36ecd6d.

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

Comment thread src/app/page.tsx
Comment on lines +65 to +74
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && 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 | ⚡ Quick win

Keyboard shortcut fails when Caps Lock is enabled.

The condition e.key === 'k' is case-sensitive. When Caps Lock is on, e.key will be 'K' (uppercase), causing the shortcut to be ignored.

⌨️ Proposed fix
   useEffect(() => {
     const handleKeyDown = (e: KeyboardEvent) => {
-      if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
+      if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'k') {
         e.preventDefault()
         searchInputRef.current?.focus()
       }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
e.preventDefault()
searchInputRef.current?.focus()
}
}
window.addEventListener('keydown', handleKeyDown)
return () => window.removeEventListener('keydown', handleKeyDown)
}, [])
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'k') {
e.preventDefault()
searchInputRef.current?.focus()
}
}
window.addEventListener('keydown', handleKeyDown)
return () => window.removeEventListener('keydown', handleKeyDown)
}, [])
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/app/page.tsx` around lines 65 - 74, The shortcut handler in useEffect
(handleKeyDown) compares e.key case-sensitively so it fails with Caps Lock on;
update the condition to be case-insensitive (e.g., compare e.key.toLowerCase()
=== 'k') or use the physical key code (e.code === 'KeyK') to detect the K key
regardless of Caps Lock, then keep the existing e.preventDefault() and
searchInputRef.current?.focus() behavior.

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