Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): Add keyboard shortcuts for navigating between sidebar panels #3477

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

metaboulie
Copy link
Contributor

📝 Summary

Add keyboard shortcuts to navigate between panels in the sidebar, making it easier for users to switch between different views without using the mouse. The shortcuts are Ctrl-Shift-{ and Ctrl-Shift-}.

Bildschirmaufnahme.2025-01-17.um.20.16.36.mov

🔍 Description of Changes

  • Added two new hotkey definitions in hotkeys.ts:
    • panel.nextPanel: Navigate to next panel (Ctrl/Cmd-Shift-})
    • panel.previousPanel: Navigate to previous panel (Ctrl/Cmd-Shift-{)
  • Added state management actions in chrome/state.ts to handle panel navigation:
    • nextPanel: Cycles to the next visible panel
    • previousPanel: Cycles to the previous visible panel
  • Connected hotkeys to panel navigation in app-chrome.tsx using useHotkey hook
  • Navigation only works when the sidebar is open
  • Navigation cycles through visible panels in the order they appear in the sidebar

📋 Checklist

  • I have read the contributor guidelines.
  • The change is self-contained and focused on improving keyboard navigation.
  • The code follows existing patterns for hotkey implementation and state management.
  • I have run the code and verified that the panel navigation works as expected.

📜 Reviewers

@akshayka OR @mscolnick

Add Ctrl-Shift-{ and Ctrl-Shift-} shortcuts to navigate between
panels in the sidebar. The navigation only works when the sidebar is
open and cycles through visible panels in order.

- Add panel.nextPanel and panel.previousPanel hotkey definitions
- Add nextPanel and previousPanel actions to chrome state management
- Register hotkey handlers in AppChrome component
Copy link

vercel bot commented Jan 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 18, 2025 10:38am

Copy link

vercel bot commented Jan 17, 2025

@metaboulie is attempting to deploy a commit to the marimo Team on Vercel.

A member of the Team first needs to authorize it.

@mscolnick
Copy link
Contributor

Ctrl-Shift-{ and Ctrl-Shift-} is used to move tabs in the browser, so this might be a bad default. I would be open to

  1. making them NOT_SET so people can set them if they'd like. vscode doesn't seem to have a way to cycle through.
  2. making just move next F3 (or a similar F-key), and prev is NOT_SET. so they can cycle through them, instead of navigate back and forth
  3. doing F3 and Shift-F3

vscode uses F3 for a lot of next/prev
Screenshot 2025-01-17 at 10 37 11 AM

Make panel.nextPanel and panel.previousPanel hotkeys configurable by
setting them to NOT_SET by default. This allows users to set their
preferred key bindings through the hotkeys menu or marimo.toml rather
than having hardcoded defaults.
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.

2 participants