Repository navigation
Conversation
polybjorn
marked this pull request as ready for review
May 3, 2026 13:05
polybjorn
marked this pull request as draft
May 3, 2026 23:17
polybjorn
marked this pull request as ready for review
May 3, 2026 23:41
This was referenced May 4, 2026
Alkarex
pushed a commit
that referenced
this pull request
May 4, 2026
Mapco and Ansum apply `transition: all 0.2s ease-in-out` to `.aside` in their narrow `@media`. When the viewport crosses 840px with the sidebar open, the resulting `.aside` position change (`static` to `fixed`) gets animated alongside width, producing a visible artefact where the X button slides down then scrolls back up before settling. Limit the transition to the property that should actually animate (`width`), matching base-theme's existing `transition: width 200ms linear`. The artefact only manifests when the drawer stays open across the 840px boundary, which is the behaviour introduced by #8775. On current edge, `init_nav_menu`'s `media.onchange` toggles the aside off when crossing the breakpoint, hiding the bug. Co-authored-by: Bjørn A. Andersen <[email protected]>
Sidebar state was tracked across three runtime classes (`.aside.is-hidden`, `.aside.visible`, and `.btn.active`) maintained by main.js, plus a viewport-dependent default in CSS. Keeping these in sync caused #8771: removing one piece of state broke another that implicitly relied on it. The split also meant the server couldn't know per-tab state at render time, so every navigation showed a brief sidebar flash while JS reconciled after first paint. Move the source of truth to a single `:root.aside_hidden` class, mirroring the existing `:root.darkMode_*` convention. Resolution order: 1. sessionStorage state if user has toggled in this tab 2. otherwise hidden in reader view 3. otherwise hidden at narrow viewport (mobile drawer pattern) 4. otherwise the user's `sidebar_hidden_by_default` setting `p/scripts/aside_init.js` runs synchronously in <head> before <body> paints, so the class is present at first paint and the sidebar drawer no longer flashes. Loaded as an external file because CSP `'self'` blocks inline scripts. The narrow-viewport default applies on all views; the sessionStorage lookup and user-preference fallback are gated to toggleable views (normal and reader) where the toggle button exists. Drop `.is-hidden` and `.visible` from JS and CSS entirely. Themes that overrode these selectors are rewritten to scope from `:root.aside_hidden` / `:root:not(.aside_hidden)`. The toggle button's active state is similarly derived from root state via `:root:not(.aside_hidden) #nav_menu_toggle_aside .btn` rather than a runtime `.active` class, eliminating the brief flicker on the toggle button during page navigation. Touches Flat, Origine, Alternative-Dark, Dark, Pafat, Nord, and Swage plus their RTL counterparts. Themes with no `.btn.active` rule (Mapco, Ansum, Origine-compact, Dark-pink) are unaffected by the toggle change. Use `display: block` rather than `display: revert` for the narrow-drawer <nav> rule; semantically identical here but broader browser support (revert only landed in 2020). Preserves: per-tab sessionStorage semantics, per-view keying, narrow/reader defaults, the `sidebar_hidden_by_default` setting. Supersedes the `init_nav_menu` gate fix in #8773.
The sidebar overlays content at <=840px, so a wide-view "open" choice must not leak into narrow: - aside_init.js: narrow and reader force-hide above the stored branch, preventing the overlay from flashing on initial paint after a fresh page load at narrow with a sticky wide-session "open" state. - main.js: viewport-crossing handler force-hides on entering narrow without persisting, and restores the stored choice on entering wide, so the round trip preserves the wide-view preference.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The sidebar and its toggle button flash briefly on every page navigation. This PR decides their visibility state in
<head>, before the browser paints anything, so there's nothing to flash. Also consolidates the state model onto one CSS class instead of three, removing the bug class that caused #8771. Mirrors the existing:root.darkMode_*convention. Supersedes the gate fix in #8773.What's wrong today
The flash. The server can't know your per-tab sidebar state, that's in
sessionStorage, browser-only. So PHP renders a default, JS corrects it after first paint, and you see the gap, both for the sidebar drawer and for the toggle button's active styling.State sprawl. Sidebar visibility was tracked across three runtime classes (
.aside.is-hidden,.aside.visible,.btn.active) that JS had to keep in sync. #8771 happened because removing one piece broke another that implicitly relied on it.Approach
Single source of truth: a
:root.aside_hiddenclass on<html>. Present means hidden, absent means visible. CSS reads it for both the sidebar drawer and the toggle button. JS toggles it.p/scripts/aside_init.jsruns synchronously in<head>, before the browser paints<body>. Resolution order:sidebar_hidden_by_defaultsettingThe narrow-viewport default applies on all views; sessionStorage and user-preference steps are gated to views with the toggle button (normal, reader).
Why a new script file
The init can't live in
main.js: that script isdefer async, runs after first paint, too late. Loadingmain.jssynchronously would block parsing for ~50KB. Inlining would be smallest but CSP'self'blocks inline scripts. A small external file (~500 bytes, cacheable) is the cheapest option that satisfies all three.What changes
.asidevisibility rules across base-theme + 4 themes (Origine, Swage, Alternative-Dark, Nord) rewritten to scope from:root.aside_hidden/:root:not(.aside_hidden)instead of.aside.is-hidden/.aside.visible. Narrow drawer collapse useswidth: 0to preserve the slide animation.:root:not(.aside_hidden) #nav_menu_toggle_aside .btnin every theme that styles.btn.active(Flat, Origine, Alternative-Dark, Dark, Pafat, Nord). The.classList.toggle('active')JS calls and the PHP-rendered.activeclass are gone.toggle_aside_click()is a thin wrapper aroundsetAsideHidden(hidden, manual).init_nav_menu()only wires event handlers and a media-query handler now; state restoration is done by the inline init.Tested