Skip to content

feat(web): add arrow-key navigation for sidebar #1083

Open
Xanacas wants to merge 1 commit intopingdotgg:mainfrom
Xanacas:feat/sidebar-arrow-navigation
Open

feat(web): add arrow-key navigation for sidebar #1083
Xanacas wants to merge 1 commit intopingdotgg:mainfrom
Xanacas:feat/sidebar-arrow-navigation

Conversation

@Xanacas
Copy link
Contributor

@Xanacas Xanacas commented Mar 14, 2026

Summary

  • Add keyboard arrow navigation (Up/Down/Left/Right) for the sidebar project/thread tree
  • ArrowLeft collapses a project or jumps to its parent; ArrowRight expands or focuses the first child thread
  • Skips collapsed project threads when navigating with Up/Down
  • Uses aria-expanded for accessibility instead of a custom data-expanded attribute
  • Extracted navigation logic into Sidebar.logic.ts with 12 unit tests

Note

Add arrow-key navigation for sidebar projects and threads

  • Adds handleSidebarArrowNavigation in Sidebar.logic.ts to handle ArrowUp/ArrowDown/ArrowLeft/ArrowRight key events on the sidebar menu.
  • ArrowUp/ArrowDown move focus between projects and threads, skipping threads under collapsed projects.
  • ArrowLeft on a thread focuses its parent project; on an expanded project, collapses it. ArrowRight expands a collapsed project or focuses its first thread.
  • Navigation is wired in Sidebar.tsx via an onKeyDown handler on SidebarMenu, with data-nav-item and aria-expanded attributes added to project and thread buttons.
  • Navigation ignores events when focus is on an input or textarea.

Macroscope summarized ce62140.

@coderabbitai
Copy link

coderabbitai bot commented Mar 14, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d6e72740-0970-4b69-a6cc-53d1d2d0ec3c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 14, 2026
@Xanacas Xanacas marked this pull request as ready for review March 14, 2026 17:03
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>
@Xanacas Xanacas force-pushed the feat/sidebar-arrow-navigation branch from ce62140 to 50063ad Compare March 14, 2026 17:14
@Xanacas Xanacas changed the title feat(web): add arrow-key navigation for sidebar feat(web): add arrow-key navigation for sidebar (size:large but very isolated and streight forwards) Mar 14, 2026
@Xanacas Xanacas changed the title feat(web): add arrow-key navigation for sidebar (size:large but very isolated and streight forwards) feat(web): add arrow-key navigation for sidebar Mar 14, 2026
@Xanacas
Copy link
Contributor Author

Xanacas commented Mar 14, 2026

@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.

My preference would be:
Tab just focuses the project-list, not an individual entry. switching "focus" between projects happens then by standard WAI-ARIA Treeview pattern (up,down,left,right arrow keys). This would make tab navigation much more practical especially if there are a lot of projects/threads in the sidebar.
Color wise I then would prefer to have the current focused projects/threads ring being the grey tone it currently had accidentally.
Following this concept, there is a minor change that could matter for some users. currently I can tab to the "new thread" butten behind the project name. this would work anymore. My perspective: If I am using keyboard shortcuts to navigate, I can easily learn (or would have learned already) that mod+shift+n does the same thing. I'd probably just add a "n" keyboard shortcut that works when on a project to create a new thread even if I'm not on a thread of the current focused project.

So this one is really only adding arrow-key navigation following best practices for tree view navigation.
If you'd be willing to also accept the mentioned change towards the tree view only be one focusable entry, please let me know.

const navType = currentItem.dataset.navItem;
const projectId = currentItem.dataset.projectId as ProjectId | undefined;

if (key === "ArrowUp") {
Copy link
Member

Choose a reason for hiding this comment

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

Should these be configurable and integrated into the centralized keybindigns system?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants