Skip to content

🎨 Palette: Add Cmd+K search shortcut and visual hint - #73

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

🎨 Palette: Add Cmd+K search shortcut and visual hint#73
mkk2026 wants to merge 1 commit into
masterfrom
palette-ux-search-shortcut-16483960964175090890

Conversation

@mkk2026

@mkk2026 mkk2026 commented Feb 24, 2026

Copy link
Copy Markdown
Owner

Implemented a Cmd+K (or Ctrl+K) keyboard shortcut for the main search input in the security dashboard. This improves accessibility and power-user navigation.

Key Changes:

  • Added useRef and useEffect to src/app/page.tsx to handle the keydown event.
  • Added a visual ⌘K badge inside the search input that is conditionally rendered when the input is empty.
  • Added aria-keyshortcuts="Control+K Meta+K" to the input element.
  • Verified the functionality with a Playwright script and manual inspection of screenshots.

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

Summary by CodeRabbit

  • New Features
    • Added Cmd+K / Ctrl+K keyboard shortcut to quickly focus the search input.
    • Visual indicator displays the shortcut hint when search is empty, automatically hidden when typing begins.

- Adds a global keyboard shortcut (Cmd+K / Ctrl+K) to focus the search input.
- Adds a visual "⌘K" hint to the search input that automatically hides when the user types.
- Adds `aria-keyshortcuts` attribute for accessibility.
- Ensures the hint does not overlap with the clear button or input text.
- Updates `.jules/palette.md` with a journal entry about search input shortcuts.

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 Feb 24, 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 Feb 24, 2026 0:16am

@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 Feb 24, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR introduces keyboard shortcut support for search input focus and adds documentation for the feature. Changes include a new specification file and implementation of Cmd+K/Ctrl+K listener with visual hint in the search component.

Changes

Cohort / File(s) Summary
Documentation
.jules/palette.md
New specification file documenting Cmd+K/Ctrl+K keyboard shortcut behavior for search inputs, including listener implementation and visual hint display/hiding logic.
Search Component Enhancement
src/app/page.tsx
Added useRef hook for search input, global keydown listener for Cmd+K/Ctrl+K focus, aria-keyshortcuts attribute, and conditional keyboard shortcut badge displayed when search query is empty.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A keyboard shortcut, swift and keen,
Cmd+K guides where searches convene,
With badges that dance and hints that hide,
The search input blooms with hoppy pride!

🚥 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 includes an emoji and uses 'Palette:' as a prefix, but accurately describes the main functional changes: adding a Cmd+K keyboard shortcut and visual hint for the search input, which aligns with the changeset's primary purpose.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch palette-ux-search-shortcut-16483960964175090890

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: 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 `@src/app/page.tsx`:
- Around line 370-374: Detect the user platform client-side and render the
correct shortcut label instead of always showing "⌘K": add a state like isMac in
the component (initialize to false to avoid SSR/hydration issues) and set it
inside a useEffect by checking navigator.platform / navigator.userAgent for Mac
identifiers; then update the JSX that currently renders the kbd (the block gated
by !searchQuery) to show "⌘K" when isMac is true and "Ctrl+K" otherwise (or
similar localized text), keeping the rest of the kbd styling intact.
- Around line 58-67: The global keyboard handler handleKeyDown inside the
useEffect is hijacking native Cmd/Ctrl+K behavior in editable fields; update
handleKeyDown to first ignore events originating from editable elements by
checking the event target (e.g., if target is an INPUT, TEXTAREA, or has
isContentEditable true) and early-return in those cases, then proceed to detect
the k + meta/ctrl combo and focus searchInputRef; keep the existing
addEventListener/removeEventListener logic in the useEffect and only change the
handler body to include this editable-target guard.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

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

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

Comment thread src/app/page.tsx
Comment on lines +58 to +67
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key.toLowerCase() === 'k' && (e.metaKey || e.ctrlKey)) {
e.preventDefault()
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.

⚠️ Potential issue | 🟡 Minor

Don’t hijack Cmd/Ctrl+K while the user is editing text.

On macOS, Cmd+K deletes to end of line in inputs; this listener currently prevents that (and can interfere in other editable fields). Consider ignoring events from editable targets.

🛠️ Suggested guard to preserve native editing
   const handleKeyDown = (e: KeyboardEvent) => {
+    const target = e.target as HTMLElement | null
+    const isEditable =
+      target &&
+      (target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName))
+    if (isEditable) return
     if (e.key.toLowerCase() === 'k' && (e.metaKey || e.ctrlKey)) {
       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.key.toLowerCase() === 'k' && (e.metaKey || e.ctrlKey)) {
e.preventDefault()
searchInputRef.current?.focus()
}
}
document.addEventListener('keydown', handleKeyDown)
return () => document.removeEventListener('keydown', handleKeyDown)
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
const target = e.target as HTMLElement | null
const isEditable =
target &&
(target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName))
if (isEditable) return
if (e.key.toLowerCase() === 'k' && (e.metaKey || e.ctrlKey)) {
e.preventDefault()
searchInputRef.current?.focus()
}
}
document.addEventListener('keydown', handleKeyDown)
return () => document.removeEventListener('keydown', handleKeyDown)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/page.tsx` around lines 58 - 67, The global keyboard handler
handleKeyDown inside the useEffect is hijacking native Cmd/Ctrl+K behavior in
editable fields; update handleKeyDown to first ignore events originating from
editable elements by checking the event target (e.g., if target is an INPUT,
TEXTAREA, or has isContentEditable true) and early-return in those cases, then
proceed to detect the k + meta/ctrl combo and focus searchInputRef; keep the
existing addEventListener/removeEventListener logic in the useEffect and only
change the handler body to include this editable-target guard.

Comment thread src/app/page.tsx
Comment on lines +370 to +374
{!searchQuery && (
<div className="absolute right-4 top-1/2 transform -translate-y-1/2 pointer-events-none">
<kbd className="inline-flex h-5 select-none items-center gap-1 rounded border border-slate-200 bg-slate-100 px-1.5 font-mono text-[10px] font-medium text-slate-500 opacity-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-400">
<span className="text-xs">⌘</span>K
</kbd>

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

Show the correct shortcut hint on non‑mac platforms.

Right now Windows/Linux users still see ⌘K. Consider a platform-aware label (Ctrl+K) to avoid misleading guidance.

💡 Example rendering tweak
-                          <kbd className="inline-flex h-5 select-none items-center gap-1 rounded border border-slate-200 bg-slate-100 px-1.5 font-mono text-[10px] font-medium text-slate-500 opacity-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-400">
-                            <span className="text-xs">⌘</span>K
-                          </kbd>
+                          <kbd className="inline-flex h-5 select-none items-center gap-1 rounded border border-slate-200 bg-slate-100 px-1.5 font-mono text-[10px] font-medium text-slate-500 opacity-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-400">
+                            {isMac ? <span className="text-xs">⌘</span> : <span className="text-[10px]">Ctrl</span>}
+                            <span className="text-[10px]">{isMac ? 'K' : '+K'}</span>
+                          </kbd>

You can derive isMac in a useEffect to avoid SSR/hydration mismatches.

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

In `@src/app/page.tsx` around lines 370 - 374, Detect the user platform
client-side and render the correct shortcut label instead of always showing
"⌘K": add a state like isMac in the component (initialize to false to avoid
SSR/hydration issues) and set it inside a useEffect by checking
navigator.platform / navigator.userAgent for Mac identifiers; then update the
JSX that currently renders the kbd (the block gated by !searchQuery) to show
"⌘K" when isMac is true and "Ctrl+K" otherwise (or similar localized text),
keeping the rest of the kbd styling intact.

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