-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hi there! 👋
I noticed that commit 8f49267 (which resolved zensical/zensical#4) introduced a couple of regressions regarding keyboard navigation and search behavior.
1. Navigation shortcuts bypass instant navigation
The shortcuts ., ,, n, and p currently use window.location.href directly, which forces a full page reload even when instant navigation is enabled.
ui/src/assets/javascripts/bundle.ts
Lines 188 to 202 in 8f49267
| case ",": | |
| case "p": | |
| const prev = document.querySelector("link[rel=prev]") | |
| if (prev instanceof HTMLLinkElement) | |
| window.location.href = prev.href | |
| break | |
| // Go to next page | |
| case ".": | |
| case "n": | |
| const next = document.querySelector("link[rel=next]") | |
| if (next instanceof HTMLLinkElement) | |
| window.location.href = next.href | |
| break | |
In contrast, mkdocs-material uses setLocation() to respect the instant navigation feature:
https://github.com/squidfunk/mkdocs-material/blob/master/src/templates/assets/javascripts/bundle.ts#L189-L200
Actually in 8f49267 you did import setLocation but didn't use it.
2. Search shortcut (/) issues
When pressing / to open search:
- The
preventDefaultisn't called, so the/character gets typed into the input field if focused. - Pressing
Esccloses the panel but doesn't blur the input or reset focus properly. If you type/->Esc->123->/, you'll find123typed into the search box.
ui/src/assets/javascripts/bundle.ts
Lines 204 to 209 in 8f49267
| case "/": | |
| const el = document.querySelector("[data-md-component=search] button") | |
| if (el instanceof HTMLButtonElement) | |
| el.click() | |
| break | |
It would be great to align these behaviors with the expected SPA experience. Thanks for your work on this! 🚀