Repository navigation
fix(js): stop sidebar auto-reopening on page navigation - #8773
Merged
Merged
Conversation
After #8747 the sidebar would re-open on its own when navigating (e.g. clicking the logo) on sessions where sessionStorage said the sidebar should be closed. init_nav_menu() ran toggle_aside_click() to honour the stored state, then gated a follow-up `.visible` re-add on `getComputedStyle(aside).display !== 'none'`. Before #8747 that gate worked because the close path set `aside.style.display = 'none'` inline; #8747 replaced that with an `is-hidden` class applied only at wide viewports, so at narrow viewports the computed display stays `table-cell` after closing and the gate wrongly re-adds `.visible`, sliding the drawer open. Gate on the toggle button's `.active` state instead. It's the real source of truth for "should the sidebar be open" and is already used elsewhere in the same function. Fixes #8771
Alkarex
approved these changes
May 3, 2026
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.
Summary
Fixes #8771. My earlier #8747 broke this: at narrow viewports the sidebar re-opens by itself when navigating (e.g. clicking the logo) on sessions where it was previously closed.
That PR removed an inline
aside.style.display = 'none'from the sidebar close path. A check further down ininit_nav_menu()was implicitly relying on it to detect "sidebar is currently hidden":At narrow viewports
aside's computed display staystable-cellafter a close (the narrow@mediahides viawidth: 0, notdisplay), so the check now always passes and re-adds.visible.Fix
Gate on
toggle_aside.classList.contains('active')instead, the actual source of truth for whether the sidebar should be open.