Skip to content

refactor(keyboard-nav): share a single nav instance via KeyboardNavProvider#45

Merged
viralcodex merged 1 commit into
mainfrom
keyboard-nav-provider
Jul 7, 2026
Merged

refactor(keyboard-nav): share a single nav instance via KeyboardNavProvider#45
viralcodex merged 1 commit into
mainfrom
keyboard-nav-provider

Conversation

@viralcodex

Copy link
Copy Markdown
Owner

Summary

  • Splits useKeyboardNav into createKeyboardNav (constructor) + useKeyboardNav (context consumer) so panels can share one focus ring
  • Adds KeyboardNavProvider and wraps the active tool + preview subtree in it inside main-ui.tsx
  • Adds persistent?: boolean to FocusableElement so long-lived focusables survive clearElements() between effect reruns

Behavior notes

  • Callers outside the provider fall back to createKeyboardNav() (unchanged behavior for standalone components).
  • Callers inside the provider now share one ring — tool components (merge/compress/etc.) and pdf-preview will cycle through each other's focusables. This is the intended unified focus behavior.

Test plan

  • bun run typecheck clean
  • bun test — 107/107 pass
  • Manual: verify focus cycling in merge/compress/rotate still works
  • Manual: verify tools-menu (outside provider) still cycles independently

Follows up in

  • File-list double-E shortcut (separate PR)
  • PDF-preview arrow key navigation (separate PR)
  • Page Numbers feature (depends on this PR)

…ovider

Splits useKeyboardNav into createKeyboardNav (constructor) and useKeyboardNav
(context consumer) so descendant panels can share one focus ring instead of
each panel spinning up its own. main-ui wraps its tool + preview subtree in the
new provider. Adds a persistent field to FocusableElement so consumers can
keep long-lived focusable elements registered across effect reruns
(clearElements now only drops non-persistent entries).

Callers outside the provider fall through to a fresh instance, preserving
current behavior for standalone components.
@viralcodex viralcodex merged commit a28945d into main Jul 7, 2026
1 check passed
@viralcodex viralcodex deleted the keyboard-nav-provider branch July 7, 2026 18:11
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