-
Notifications
You must be signed in to change notification settings - Fork 535
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
refactor(PageLayout): update sticky layout #2326
Conversation
🦋 Changeset detectedLatest commit: 96313cd 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 |
@colebemis one thing I noticed when testing is a |
size-limit report 📦
|
We don't have any kind of z-index system. Let's bump the z-index and call it a day 😉 |
Perfect, thanks @colebemis! |
Just wanted to follow up here, reached out over in web systems and paired up with @jonrohan to see what we could do with this pattern to avoid the "jumpiness". When researching more, it seems like this behavior occurs in the original codepen and other implementations across Primer. Below are two examples from different areas:
I tried to take existing videos and slow them down to show where the jump was coming from, hope it makes it clearer! It seems like the root cause is the time it takes to update the height of the pane in order for As an interim trade-off, this PR uses native Hope that makes sense, let me know if there are any questions! |
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.
Thanks for doing a thorough evaluation of our options here, @joshblack! This PR feels like our best option at this point. Let's go ahead and merge it. As you said, we can revisit this later if we find a better solution.
Co-authored-by: Cole Bemis <colebemis@github.com>
…nto update-sticky-page-layout
Closes https://github.com/github/primer/issues/1264
This PR presents an alternative to our
PageLayout.Pane
behavior in order to address some of these issues that have come up when using the existing implementation. Specifically, there are two challenges that have been identified:PageLayout.Pane
will jump due toposition: sticky
Screen.Recording.2022-09-09.at.4.03.11.PM.mov
This is due to the default implementation of
position: sticky
in the browser. At a certain point, the browser will scroll past the sticky parent and will scroll the overall viewport.In the existing implementation, the height will re-calc and cause the sticky parent to come back into the viewport. This is what creates the jump as
position: sticky
comes back into playPageLayout.Pane
will jump around when scrollingScreen.Recording.2022-09-09.at.4.04.53.PM.mov
This is due to the height of
PageLayout.Pane
changing as a result of scrolling. In order to keep the elements in view within the scrolled container, it will attempt to restore the scroll position after the height changes. This leads to a jumpy effectProposal
This PR makes some trade-offs to allow for a sticky
PageLayout.Pane
without some of the challenges described above. Specifically, when encounteringPageLayout.Footer
(or another footer) thePageLayout.Pane
component will followposition: sticky
behavior and will not stick to the top.Screen.Recording.2022-09-12.at.5.14.25.PM.mov
This approach keeps
position: sticky
in tack and avoids the jumpy-ness of previous attempts but unfortunately will not keepPageLayout.Pane
stuck to the top when the footer comes into view as a result