Skip to content

feat(pdf-preview): navigate pages with arrow keys and hjkl#47

Merged
viralcodex merged 2 commits into
mainfrom
pdf-preview-keynav
Jul 7, 2026
Merged

feat(pdf-preview): navigate pages with arrow keys and hjkl#47
viralcodex merged 2 commits into
mainfrom
pdf-preview-keynav

Conversation

@viralcodex

@viralcodex viralcodex commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Registers prev/next page buttons as persistent focusable elements so tab-cycle reaches them and focus state renders correctly.
  • Adds left/right and h/l key bindings that flip pages when a PDF is selected, matching the existing button click behavior.
  • Suppresses bindings while a text input has focus or no file is selected.

Depends on #45 (KeyboardNavProvider + persistent field on FocusableElement).

Test plan

  • bun run typecheck
  • bun test (107/107 pass)
  • Manual: select a PDF, tap left/right and h/l — page counter advances/rewinds within bounds.
  • Manual: focus a text input elsewhere and confirm the bindings no longer fire.

…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.
Registers the prev/next page buttons as persistent focusable
elements and adds left/right (and h/l) key bindings so users
can flip through a previewed PDF without the mouse.

Suppressed while a text input has focus or when no file is
selected.
@viralcodex viralcodex merged commit 8c85fec into main Jul 7, 2026
1 check passed
@viralcodex viralcodex deleted the pdf-preview-keynav 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