Repository navigation
Keep the sidebar closed once it has been closed - #556
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Closes #545
Cause
Every page renders its own
<Layout>, so going to another page rebuilds the layout, anduseExpandedstarted from "open" each time. The sidebar therefore reopened on every page change and every reload.Fix
useExpandednow remembers the choice outside the component: in memory (so moving between pages doesn't flicker) and in the browser'slocalStorage(so it survives a reload). The saved value is read before the first paint, so a closed sidebar doesn't flash open on load. Default is still open, and if storage is blocked (private mode) it still holds for the visit.It's per browser, like the theme was before #555. It isn't saved to the account.
Testing
useExpanded.test.tsx(5 tests): starts open, stays closed across pages, stays closed after a reload, reopening is remembered, works with storage blocked. 3 of them fail without the change. Typecheck (apart from the existinggetJsonSchema.test.tserrors), lint and the full suite pass. Not yet checked in a browser: please close the sidebar, click through a few pages, and reload.🤖 Generated with Claude Code