-
-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sidebar state persistence #2150
Conversation
🦋 Changeset detectedLatest commit: 81c2578 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for astro-starlight ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
size-limit report 📦
|
Made an experimental update in 06dc927 to see if it might handle sidebars with collapsed groups better. Still needs some cleanup probably but the principle here is to only persist sidebar collapse state that has been directly modified by user interaction. In other words, given a four group sidebar with each group marked with
In theory, this improves the experience for sidebars with lots of collapsed groups. Nevertheless, it may also be somewhat confusing as it introduces two behaviours in parallel:
Will need some user testing and feedback to decide whether something like this change makes sense! |
This comment was marked as outdated.
This comment was marked as outdated.
This reverts commit c5a9072.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks perfect to me, the best of all tested versions 🌟 Amazing work and such a great improvement! 🎉
Small question: I think the Lunaria Status Overview is outdated/invalid as you removed all the test pages in ae66035 ?
Yes! I asked @yanthomasdev about it — it’s a small bug where the Lunaria action bails early when it finds no content files, which means it couldn’t update that comment. |
Description
Scope
How does it work?
href
)sessionStorage
each page visitMore technical details
Page.astro
so it always runs, even in the absence of a sidebar. This makes sure visiting a page without a sidebar “clears” the stored state. Otherwise, for example, visiting the Starlight docs homepage and then returning to a docs page persists state, which feels wrong, I think. (Again, thinking about this as a UX improvement specific to navigating between pages with a shared sidebar.)<Sidebar>
component. In general, we try to keep logic out of these components to help make overriding simpler, and in an earlier commit the has was added as asidebarHash
property to the route data object. There are pros and cons to both approaches but I think this is the right way based on:Sidebar.astro
to ensure it runs as soon as the sidebar HTML is complete.Todo
astro.config.mjs