-
-
Notifications
You must be signed in to change notification settings - Fork 538
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
Fix sidebar scroll restoration issue #2569
base: main
Are you sure you want to change the base?
Conversation
|
✅ Deploy Preview for astro-starlight ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Took a quick look at the preview and certainly seems to be working as expected. Don’t love that this forces moving more stuff out of the <SidebarPersister>
component. Maybe there’s another way to break it up 🤔 I think currently the reason to keep <SidebarPersister>
in <Sidebar>
is to receive and hash the sidebar as mutated by any sidebar overrides. Maybe after #2390 that wouldn’t be so important.
Yeah, not super happy about it either, even more it breaks Prettier now in #2390 would definitely help, altho, I'll have to find and check some previous discussions, I wonder if also one point to keep it there was also the possibility to bypass it by not rendering the default component maybe? 🤔 |
Yeah, that’s also true. Moving things to |
Description
This PR fixes a sidebar restoration issue in projects that uses a
<Sidebar>
component override which adds content after the default sidebar, e.g. like the sponsors in the Astro Docs.Repro:
The sidebar scroll position is not properly restored as it should be. The restoration happens after the default sidebar content is rendered but before the entire override content is rendered. Any extra content added after the default sidebar content is not taken into account when restoring the scroll position.
This PR is a draft testing the easiest fix by just moving the restoration script after the
<Sidebar>
component. The goal is to see if this is a viable solution and if it doesn't break anything else.The preview in this PR includes a reproduction of the issue so that we can easily test the fix.
Remaining tasks
Sidebar
override indocs/astro.config.mjs
docs/src/components/Sidebar.astro
filepackages/starlight/components/SidebarPersister.astro