feat(keys): vim-style Ctrl+w pane focus navigation#108
Merged
Conversation
Keyboard-only users could not move focus to the Playlists sidebar: on_key intercepts every keystroke and prevents Textual's native Tab traversal, so the sidebar's ListView was unreachable. Add three rebindable actions through the keymap system: - Ctrl+w h -> Playlists sidebar (auto-shows it if hidden) - Ctrl+w l -> main content, then lyrics when the lyrics pane is visible - Ctrl+w w -> cycle focus through the visible panes Focus alone is insufficient because on_key routes movement keys to the current page regardless of Textual focus, so an _active_pane flag routes move/select/filter to the existing PlaylistSidebar.handle_sidebar_action() and the scroll subset to LyricsSidebar.handle_action(); everything else falls through to the page. Focus resets to content on hide and on page navigation. Tab stays page-local (repurposing it would regress Browse and Context). Help page + keybindings docs updated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Keyboard-only users couldn't move focus into the Playlists sidebar.
on_keyintercepts every keystroke and calls
prevent_default(), which suppressesTextual's native Tab traversal, so the sidebar's
ListViewwas unreachable —on the Library page Tab did nothing at all.
This adds three rebindable vim-style window-navigation actions through the
keymap system (remappable in
config.toml):Ctrl+w h→ Playlists sidebar (auto-shows it if hidden)Ctrl+w l→ main content, then the lyrics pane when it's visibleCtrl+w w→ cycle focus through the visible panesFocusing the widget alone isn't enough:
on_keyroutes movement keys to thecurrent page regardless of Textual focus. So a new
_active_paneflag routesmove/select/filter to the existing
PlaylistSidebar.handle_sidebar_action()and the scroll subset to
LyricsSidebar.handle_action(); everything elsefalls through to the page. Focus resets to content when the sidebar is hidden
and on page navigation. Tab stays page-local — repurposing it globally would
regress Browse (sub-tab switch) and Context (track/album cycle).
Ctrl+w his directional, matching vim splits: from the content pane itreaches Playlists; from the lyrics pane it steps to content first.
Testing
ruff format src/ tests/ruff check src/ tests/pytest tests/pytest→ 951 passed, 2 skipped.pyright src/ytm_player/→ 0 errors. Newfocused coverage in
tests/test_app/test_pane_focus.py(keymap chord parsing,the pane state machine, action routing).
Related
Updates the in-app help screen and
docs/keybindings.md(the previous "Tabfocuses the next panel" line was inaccurate). No linked issue.