feat: add vim-style keyboard navigation to SmartBlocks menu#146
feat: add vim-style keyboard navigation to SmartBlocks menu#146mdroidian merged 1 commit intoRoamJS:mainfrom
Conversation
Add Ctrl-n/Ctrl-j for down and Ctrl-p/Ctrl-k for up navigation in the workflow dropdown, complementing existing arrow key support.
WalkthroughThe Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/SmartblocksMenu.tsx (1)
111-116: Consider checking for additional modifier keys to prevent unintended shortcut triggers.The current implementation only checks
e.ctrlKeywithout verifying that other modifiers (Shift, Alt, Meta) are not pressed. This means combinations like Ctrl+Shift+n or Ctrl+Alt+j would still trigger navigation, which may not be the intended behavior.🔎 Proposed fix to add modifier key checks
const isDown = - e.key === "ArrowDown" || - (e.ctrlKey && (e.key === "n" || e.key === "j")); + e.key === "ArrowDown" || + (e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && (e.key === "n" || e.key === "j")); const isUp = - e.key === "ArrowUp" || - (e.ctrlKey && (e.key === "p" || e.key === "k")); + e.key === "ArrowUp" || + (e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && (e.key === "p" || e.key === "k"));
Verify that overriding browser shortcuts is intentional.
The vim-style shortcuts (Ctrl+n, Ctrl+p, Ctrl+j, Ctrl+k) conflict with common browser shortcuts (new window, print, downloads, search). While
preventDefault()prevents the default browser actions, users might still expect these shortcuts to perform their standard browser functions.Can you confirm this is intentional? Vim users typically expect these keybindings, but it may cause confusion for users who accidentally trigger them while trying to use browser shortcuts.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/SmartblocksMenu.tsx
🔇 Additional comments (1)
src/SmartblocksMenu.tsx (1)
117-128: Nice refactoring to support multiple navigation shortcuts!The implementation correctly maintains the existing cycling behavior while extending support for vim-style keybindings. The use of
isDownandisUpvariables improves readability and makes the intent clear. Event propagation and prevention are handled appropriately.
|
Nice! Thanks 🙌 |
…w from rebase Rebase silently dropped these changes. Restores: - popoverProps with overflow CSS for hotkey dropdown (RoamJS#147) - Ctrl+n/j/p/k vim-style navigation in SmartBlocks menu (RoamJS#146) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Adds vim-style keyboard shortcuts for navigating the SmartBlocks workflow dropdown:
Ctrl-n/Ctrl-j→ move downCtrl-p/Ctrl-k→ move upThese complement the existing arrow key navigation, making it easier for vim users to quickly select workflows without leaving the home row.
Changes
keydownListenerinSmartblocksMenu.tsxto recognize Ctrl+n/j as down and Ctrl+p/k as upTesting
Tested locally by triggering the SmartBlocks menu with
jjand verifying all four Ctrl combinations navigate the dropdown correctly.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.