Skip to content

feat(a11y): add keyboard nav utilities#12

Merged
maitamdev merged 1 commit into
mainfrom
feat/keyboard-nav
Mar 4, 2026
Merged

feat(a11y): add keyboard nav utilities#12
maitamdev merged 1 commit into
mainfrom
feat/keyboard-nav

Conversation

@maitamdev
Copy link
Copy Markdown
Owner

@maitamdev maitamdev commented Mar 4, 2026

Keyboard navigation constants and list navigation handler.


Summary by cubic

Adds keyboard navigation utilities with common key constants and a list navigation helper. Improves accessibility and provides consistent arrow key handling across list-like components.

  • New Features
    • KEYS constant for Enter, Escape, ArrowUp, ArrowDown, Tab, and Space.
    • isNavigationKey to check if a pressed key is supported.
    • handleListNavigation to compute the next item index on ArrowUp/Down, clamped to bounds.

Written for commit 12d7a0e. Summary will update on new commits.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dhv-guiding-light Building Building Preview, Comment Mar 4, 2026 7:08pm

@maitamdev maitamdev merged commit 9980434 into main Mar 4, 2026
1 of 3 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 4, 2026

Warning

Rate limit exceeded

@maitamdev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c4ae177c-1f7e-43e9-834c-37b0961fe0d5

📥 Commits

Reviewing files that changed from the base of the PR and between fd049bb and 12d7a0e.

📒 Files selected for processing (1)
  • src/utils/keyboardNav.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/keyboard-nav

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.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/utils/keyboardNav.ts">

<violation number="1" location="src/utils/keyboardNav.ts:9">
P2: ArrowDown navigation can return `-1` when the list is empty, producing an invalid index.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/utils/keyboardNav.ts
}

export function handleListNavigation(e: KeyboardEvent, items: HTMLElement[], currentIndex: number): number {
if (e.key === KEYS.ARROW_DOWN) return Math.min(currentIndex + 1, items.length - 1);
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: ArrowDown navigation can return -1 when the list is empty, producing an invalid index.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/keyboardNav.ts, line 9:

<comment>ArrowDown navigation can return `-1` when the list is empty, producing an invalid index.</comment>

<file context>
@@ -0,0 +1,13 @@
+}
+
+export function handleListNavigation(e: KeyboardEvent, items: HTMLElement[], currentIndex: number): number {
+  if (e.key === KEYS.ARROW_DOWN) return Math.min(currentIndex + 1, items.length - 1);
+  if (e.key === KEYS.ARROW_UP) return Math.max(currentIndex - 1, 0);
+  return currentIndex;
</file context>
Fix with Cubic

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