feat(web): add arrow-key navigation for sidebar #1083
feat(web): add arrow-key navigation for sidebar #1083Xanacas wants to merge 1 commit intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Enable keyboard navigation in the sidebar using arrow keys: - ArrowUp/Down to move between visible items - ArrowLeft to collapse a project or jump to parent project from a thread - ArrowRight to expand a project or focus its first thread - Uses aria-expanded for accessibility - Only calls preventDefault when focus is on a nav item Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ce62140 to
50063ad
Compare
|
@juliusmarminge as you already merged #1079 and mostlikely did read the comment in that PR: This PR is the implementation of the arrow keys, but without the change of the tab order /without limiting the sidebar to only be focusable as one element.
So this one is really only adding arrow-key navigation following best practices for tree view navigation. |
| const navType = currentItem.dataset.navItem; | ||
| const projectId = currentItem.dataset.projectId as ProjectId | undefined; | ||
|
|
||
| if (key === "ArrowUp") { |
There was a problem hiding this comment.
Should these be configurable and integrated into the centralized keybindigns system?
There was a problem hiding this comment.
from my perspective not. I've never come across a different set of key bindings for walking along a tree view and as the arrow keys are bond to just the tree view, I currently can't come up with a scenario where I would want to bind my arrow keys to something other globally.
But what I'm thinking of:
Add some more global actions for key bindings:
- sidebar.treeView.focus
- sidebar.treeView.up
- sidebar.treeView.down
- sidebar.treeView.threadNext
- sidebar.treeView.threadPrev
For those I would immediately activate/load the thread (denounced). But I wanted to see if you're ok with this one 😅
Also I saw PR #69, what are your thoughts on Tanstack keyboard?
Summary
aria-expandedfor accessibility instead of a customdata-expandedattributeSidebar.logic.tswith 12 unit testsNote
Add arrow-key navigation for sidebar projects and threads
handleSidebarArrowNavigationin Sidebar.logic.ts to handleArrowUp/ArrowDown/ArrowLeft/ArrowRightkey events on the sidebar menu.ArrowUp/ArrowDownmove focus between projects and threads, skipping threads under collapsed projects.ArrowLefton a thread focuses its parent project; on an expanded project, collapses it.ArrowRightexpands a collapsed project or focuses its first thread.onKeyDownhandler onSidebarMenu, withdata-nav-itemandaria-expandedattributes added to project and thread buttons.inputortextarea.Macroscope summarized ce62140.