feat(docs): page through the guide with left/right arrow keys - #2984
feat(docs): page through the guide with left/right arrow keys#2984AnayGarodia wants to merge 7 commits into
Conversation
Add a small keyboard-nav script (wired via zensical extra_javascript) that maps ArrowLeft/ArrowRight to the previous/next footer links, matching the common paged-site pattern. A single document-level listener keeps working across instant navigation, looks up the current page's footer links on each key press, and ignores key presses while a modifier is held or a form field (e.g. the search box) is focused. Fixes maplibre#2788
Performance Comparison
|
CommanderStorm
left a comment
There was a problem hiding this comment.
I tesed it and it does not page through the docs. Am I using it wrong?
|
weird, it pages fine on my end. built the docs fresh ( my hunch is zensical serve doesn't re-read the new can drop a short screen capture of it paging if that's easier. |
CommanderStorm
left a comment
There was a problem hiding this comment.
Ok, I think I had something in the cache, can reproduce the buttons changing pages now, so it partially works now.
The search bar does not work anymore though...
| function isTypingTarget(el) { | ||
| if (!el) { | ||
| return false; | ||
| } | ||
| if (el.isContentEditable) { | ||
| return true; | ||
| } | ||
| var tag = el.tagName; | ||
| return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT'; | ||
| } |
The keydown handler only bailed when focus was in the search input, but arrowing through the search results moves focus onto a result link, so Left/Right got hijacked and navigated the page out from under the open search. Bail whenever the search overlay is open, keyed on the theme's own `#__search` toggle checkbox, so arrow-key handling stays with search.
|
good catch, reproduced and fixed. the bug was in the focus check. i only bailed when you were typing in the search box (activeElement is the input), but when you arrow down into the results the theme moves focus onto the result link - so activeElement is an now it bails whenever the search overlay is open at all, keyed on the theme's own verified against the real search UI in a local build:
on the zensical.toml suggestion: |
|
Marked ready. Re-verified the search-vs-paging interaction end to end in a fresh local build (
That covers the regression you hit (paging worked but search broke): the guard now keys on the theme's |
|
Does not currently work I think, so lets close this PR for now. |


What
Fixes #2788. Left/Right arrow keys now page through the guide via the footer prev/next links — a common paged-docs convenience.
How
A single document-level
keydownlistener mapsArrowLeft/ArrowRightto the existing footera.md-footer__link--prev/--nextanchors, wired throughextra_javascript. It survivesnavigation.instant, ignores modifier-key combos, and does nothing when a form field is focused.Testing
uvx zensical build→ "No issues found"; the script is emitted and referenced in the built HTML./installation/, ArrowRight →/run/, ArrowLeft → back to/installation/; with an input focused, ArrowRight did not navigate (guard works).