Skip to content

feat(dockview-core): spatial keyboard group focus + focus-logic refactor#1320

Merged
mathuo merged 2 commits into
masterfrom
feat/keyboard-directional-focus
Jun 11, 2026
Merged

feat(dockview-core): spatial keyboard group focus + focus-logic refactor#1320
mathuo merged 2 commits into
masterfrom
feat/keyboard-directional-focus

Conversation

@mathuo

@mathuo mathuo commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Builds on the keyboard navigation landed in #1319.

Spatial (directional) group focus

Adds Ctrl+Shift+Arrow to move focus to the group geometrically in that direction, complementing the sequential F6 / Shift+F6 cycle. From the active group's centre it picks the nearest grid group sitting predominantly along the requested axis (so left ignores a group that's mostly above/below), then activates it and lands focus on its content.

Four more rebindable keymap entries: focusGroupLeft / focusGroupRight / focusGroupUp / focusGroupDown. Defaults use Ctrl+Shift+arrows to dodge the macOS Spaces (Ctrl+arrow) and in-text word-nav (Alt+arrow) conflicts.

Refactor: focus logic moved out of DockviewComponent

The focusX host methods carried real feature logic (gridview traversal, the geometry math, focus retention) inside the already-large DockviewComponent. Moved into AccessibilityService where keyboard navigation belongs; the host now exposes only adjacentGroup(group, reverse) — the one piece that genuinely needs grid internals — plus the existing activeGroup. The service drives tab switching, group cycling, spatial focus and focus retention via the public group API.

Net: ~90 lines of logic out of dockviewComponent.ts, ~20 in. Behaviour unchanged.

Tests

1086 passing. Spatial geometry covered via mocked getBoundingClientRect (a 2x2 grid; jsdom has no layout); focus retention asserted by spying on focusContent.

🤖 Generated with Claude Code

mathuo and others added 2 commits June 11, 2026 18:12
Add Ctrl+Shift+Arrow to focus the group geometrically in that direction,
complementing the sequential F6 / Shift+F6 cycle. From the active group's
centre, picks the nearest grid group that sits predominantly along the
requested axis (so 'left' ignores a group that's mostly above/below), then
sets it active and lands focus on its content.

Four more rebindable keymap entries: focusGroupLeft / Right / Up / Down.
Defaults use Ctrl+Shift+arrows to dodge the macOS Spaces (Ctrl+arrow) and
in-text word-nav (Alt+arrow) conflicts; rebind via keymap as needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Service

The focusX host methods carried real feature logic (gridview traversal,
spatial geometry, focus retention) inside the already-large DockviewComponent.
Move it into AccessibilityService, where keyboard navigation belongs, and
shrink the host to a narrow primitive surface: the component now exposes only
`adjacentGroup(group, reverse)` (the gridview-order traversal that genuinely
needs grid internals) plus the existing `activeGroup`. The service drives tab
switching, group cycling, spatial focus and focus retention via the public
group API (group.model.moveToNext/focusContent, group.api.setActive).

Net: ~90 lines of logic out of dockviewComponent.ts, ~20 in. Behaviour
unchanged — the keydown-based tests pass as-is.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@mathuo mathuo merged commit 055c07c into master Jun 11, 2026
9 checks passed
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.

1 participant