Skip to content

🎨 Palette: Add keyboard shortcut hint for global search - #451

Open
mkk2026 wants to merge 1 commit into
masterfrom
feature/search-shortcut-2694539742449343186
Open

🎨 Palette: Add keyboard shortcut hint for global search#451
mkk2026 wants to merge 1 commit into
masterfrom
feature/search-shortcut-2694539742449343186

Conversation

@mkk2026

@mkk2026 mkk2026 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

What: Added a global keyboard shortcut (/) to focus the search input field, including a visual <kbd> hint and screen reader support.
Why: To improve keyboard navigation and allow power users to quickly initiate searches without reaching for the mouse, enhancing overall usability.
Before/After: The search input previously lacked a quick access shortcut. Now, pressing / focuses the field, and a visual hint is displayed when empty.
Accessibility: The visual <kbd> element is hidden from screen readers (aria-hidden="true") to prevent duplicate announcements, as the input's aria-label now includes "(Press / to focus)". The shortcut listener correctly ignores keypresses when focus is already within an input or textarea element.


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

Summary by CodeRabbit

  • New Features

    • Added a / keyboard shortcut to focus the search box.
    • Show a visual shortcut hint when the search field is empty.
  • Bug Fixes

    • Prevent the shortcut from triggering while typing in text fields.
    • Improved accessibility for the shortcut hint and search input.

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.

@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 Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a global "/" keyboard shortcut in the SecurityDashboard component to focus the search input, guarding against interference when typing in inputs/textareas, updates the input's aria-label and ref, adds a conditional visual hint, and documents the behavior in a journal file.

Changes

Search Keyboard Shortcut

Layer / File(s) Summary
Keyboard shortcut logic and UI wiring
src/app/page.tsx
Adds useRef import, a searchInputRef, and a document-level keydown listener that focuses the search input on "/" unless focus is already in an input/textarea/contenteditable; wires the ref and updated aria-label to the search <Input>, and shows a <kbd> "/" hint when the search query is empty.
Journal documentation
.Jules/palette.md
Adds a journal entry describing accessibility handling for the visual shortcut hint (aria-hidden) and guarding global shortcuts via document.activeElement checks.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Document
  participant SecurityDashboard
  participant SearchInput

  User->>Document: presses "/" key
  Document->>SecurityDashboard: keydown event
  SecurityDashboard->>SecurityDashboard: check document.activeElement
  alt not typing in input/textarea
    SecurityDashboard->>SearchInput: focus() via searchInputRef
    SecurityDashboard->>Document: preventDefault()
  else already typing
    SecurityDashboard-->>Document: ignore shortcut
  end
Loading

Possibly related PRs

  • mkk2026/Security.News.Scraper#5: Both PRs modify src/app/page.tsx to add/update the aria-label on the search input, overlapping directly at the accessibility attribute level.

Poem

A "/" key hop, a rabbit's delight,
Focus the search box, quick as light! 🐇
No stray letters where typing began,
Just a hint in a <kbd> — that's the plan.
Hop, hop, done — accessible and bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a global search keyboard shortcut and visible hint.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 feature/search-shortcut-2694539742449343186

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

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


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.

@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 56-74: The global keydown handler in the page component is too
broad because it reacts to any "/" keypress, including modifier combinations
like Ctrl+/, Cmd+/, and Alt+/. Update the `useEffect` handler in `page.tsx` to
only focus `searchInputRef` and call `preventDefault()` when "/" is pressed with
no modifier keys active, while still preserving the existing
input/textarea/contenteditable guard.
🪄 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: a738051d-02de-4b9e-b2e4-6fc090591314

📥 Commits

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

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

Comment thread src/app/page.tsx
Comment on lines +56 to +74
const searchInputRef = useRef<HTMLInputElement>(null)

useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === '/') {
// Ignore if focus is already in an input, textarea, or contenteditable
const activeElement = document.activeElement as HTMLElement
const isInput = activeElement?.tagName === 'INPUT' || activeElement?.tagName === 'TEXTAREA' || activeElement?.isContentEditable

if (!isInput) {
e.preventDefault() // Prevent "/" from being typed into the search box immediately
searchInputRef.current?.focus()
}
}
}

document.addEventListener('keydown', handleKeyDown)
return () => document.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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Guard against modifier-key combinations.

The handler only checks e.key === '/', so Ctrl+/, Cmd+/, or Alt+/ also trigger preventDefault() and steal focus, hijacking OS/browser combos that happen to use / with a modifier.

💡 Proposed fix
     const handleKeyDown = (e: KeyboardEvent) => {
-      if (e.key === '/') {
+      if (e.key === '/' && !e.ctrlKey && !e.metaKey && !e.altKey) {
         // Ignore if focus is already in an input, textarea, or contenteditable
         const activeElement = document.activeElement as HTMLElement
📝 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
const searchInputRef = useRef<HTMLInputElement>(null)
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === '/') {
// Ignore if focus is already in an input, textarea, or contenteditable
const activeElement = document.activeElement as HTMLElement
const isInput = activeElement?.tagName === 'INPUT' || activeElement?.tagName === 'TEXTAREA' || activeElement?.isContentEditable
if (!isInput) {
e.preventDefault() // Prevent "/" from being typed into the search box immediately
searchInputRef.current?.focus()
}
}
}
document.addEventListener('keydown', handleKeyDown)
return () => document.removeEventListener('keydown', handleKeyDown)
}, [])
const searchInputRef = useRef<HTMLInputElement>(null)
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === '/' && !e.ctrlKey && !e.metaKey && !e.altKey) {
// Ignore if focus is already in an input, textarea, or contenteditable
const activeElement = document.activeElement as HTMLElement
const isInput = activeElement?.tagName === 'INPUT' || activeElement?.tagName === 'TEXTAREA' || activeElement?.isContentEditable
if (!isInput) {
e.preventDefault() // Prevent "/" from being typed into the search box immediately
searchInputRef.current?.focus()
}
}
}
document.addEventListener('keydown', handleKeyDown)
return () => document.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 56 - 74, The global keydown handler in the
page component is too broad because it reacts to any "/" keypress, including
modifier combinations like Ctrl+/, Cmd+/, and Alt+/. Update the `useEffect`
handler in `page.tsx` to only focus `searchInputRef` and call `preventDefault()`
when "/" is pressed with no modifier keys active, while still preserving the
existing input/textarea/contenteditable guard.

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