-
Notifications
You must be signed in to change notification settings - Fork 615
Switch to a CSS based solution for the PageLayout sticky pane #6050
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
Conversation
🦋 Changeset detectedLatest commit: e3bbb4d 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 |
👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks! |
size-limit report 📦
|
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.
Pull Request Overview
This PR replaces the JavaScript-driven sticky pane height calculation with a pure CSS-based solution, eliminating expensive scroll/resize listeners and dynamic style recalculations.
- Removed
useStickyPaneHeight
hook and all related context plumbing - Updated
PageLayout.module.css
to use a fixed CSSmax-height
instead of a CSS variable - Updated
PageLayout.tsx
to drop the obsolete props, refs, and effects
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
packages/react/src/PageLayout/useStickyPaneHeight.ts | Deleted the JS hook that calculated pane height |
packages/react/src/PageLayout/PageLayout.tsx | Removed hook import, context values, and effects |
packages/react/src/PageLayout/PageLayout.module.css | Changed max-height to 100vh |
.changeset/warm-seals-obey.md | Added changelog entry for CSS-based solution |
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.
Changes LGTM! Just would want design to 👍 the UX changes. Is there a good way for us to test this in dotcom? Changes layout-wise terrify me lol
@joshblack Thanks for reviewing! Yes, we'll be review-labing this :) @mperrotti This is what we reviewed together, does it look ok? |
Closes https://github.com/github/primer/issues/5174
This change removes the
useResizeObserver
anduseEffect
hooks previously used to calculate and set the--sticky-pane-height
CSS custom property.Problem:
The constant recalculation and application of this style on scroll and resize events were triggering frequent and costly style recalculations (observed at 60ms+ per recalc). This significantly impacted page performance during scrolling near the top of the page. This is not even counting the React component re-render time.
Solution:
By replacing this JS code with a CSS based solution we eliminate the continuous style updates, thereby preventing the performance bottleneck caused by excessive style recalculations. The underlying layout or component manages the sticky pane's height without requiring this dynamic JavaScript-driven height adjustment.
This is a small compromise in UX that gets us big performance gains.
More context on the original implementation:
https://share.cleanshot.com/O9uSpc
Changelog
Changed
The only difference in behaviour happens on a very specific scenario:
Existing behavior:
Screen.Recording.2025-05-20.at.16.30.03.mov
New behavior:
Screen.Recording.2025-05-20.at.16.30.29.mov
Rollout strategy
Testing & Reviewing
Merge checklist