Skip to content

chore: refactor header shortcuts#2372

Open
43081j wants to merge 3 commits intomainfrom
jg/keyboard-longcuts
Open

chore: refactor header shortcuts#2372
43081j wants to merge 3 commits intomainfrom
jg/keyboard-longcuts

Conversation

@43081j
Copy link
Copy Markdown
Contributor

@43081j 43081j commented Apr 3, 2026

🔗 Linked issue

N/A

📚 Description

Just a simplification since these are getting lengthy and repetitive
already.

Just a simplification since these are getting lengthy and repetitive
already.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 3, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Apr 3, 2026 10:00pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Apr 3, 2026 10:00pm
npmx-lunaria Ignored Ignored Apr 3, 2026 10:00pm

Request Review

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 18 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/composables/useShortcuts.ts 50.00% 10 Missing and 4 partials ⚠️
app/components/AppHeader.vue 0.00% 2 Missing ⚠️
app/components/Package/Header.vue 66.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

📝 Walkthrough

Walkthrough

Centralises keyboard shortcut handling by adding a new useShortcuts composable and initKeyShortcuts() initialiser, replacing multiple per-component onKeyStroke handlers with declarative shortcut registrations. Components (Package Header, AppHeader, app.vue) now register shortcut factories that return route targets; global key handling is initialised once and navigations use navigateTo. Standalone router imports and per-component editable-element filtering were removed, and registration cleanup is handled on scope disposal. (Approx. 78 words)

Possibly related PRs

Suggested reviewers

  • danielroe
  • ghostdevv
  • antfu
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description aligns with the changeset, which involves refactoring and simplifying keyboard shortcut handlers across multiple components.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg/keyboard-longcuts

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
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
app/components/Package/Header.vue (1)

124-143: Clean refactor consolidating keyboard shortcut handlers.

The loop-driven approach reduces duplication and improves maintainability. The uniform "compute → check → preventDefault → navigate" pattern is clear.

One minor nitpick: the type annotation includes false, but the expression on line 128 (props.pkg && {...}) can only return null, undefined, or the object—never false. You could simplify the type:

🔧 Tighten the type annotation
-const shortcuts: [string, () => RouteLocationRaw | null | false | undefined][] = [
+const shortcuts: [string, () => RouteLocationRaw | null | undefined][] = [

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 45267a1e-308c-41d4-9ddf-d7b804dc0930

📥 Commits

Reviewing files that changed from the base of the PR and between 1d1f450 and 9d52025.

📒 Files selected for processing (1)
  • app/components/Package/Header.vue

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
app/components/AppHeader.vue (1)

201-204: Keep the header shortcut mapping single-sourced.

The c and , routes are now declared here and in desktopLinks, so a future key or target change can desynchronise the visible aria-keyshortcuts metadata from the handler logic. Hoisting these two definitions into one shared constant would keep this refactor aligned with its “less repetition” goal.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5c8189f-6b58-4efa-a928-c5242f2bbeca

📥 Commits

Reviewing files that changed from the base of the PR and between 9d52025 and 3b214f8.

📒 Files selected for processing (4)
  • app/app.vue
  • app/components/AppHeader.vue
  • app/components/Package/Header.vue
  • app/composables/useShortcuts.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/components/Package/Header.vue

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