fix(use-sticky): inconsistent fallback target#553
Conversation
🦋 Changeset detectedLatest commit: 728d858 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #553 +/- ##
==========================================
+ Coverage 69.23% 74.32% +5.09%
==========================================
Files 64 64
Lines 1001 1001
Branches 247 247
==========================================
+ Hits 693 744 +51
+ Misses 248 194 -54
- Partials 60 63 +3
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an inconsistency in the useSticky hook by replacing the fallback from document.body to viewport dimensions when no container is provided. This ensures consistent behavior regardless of how the document body is styled.
- Replaces
document.bodyfallback with viewport-based dimensions usingwindow.innerHeightandwindow.innerWidth - Removes the parent element validation check since the parent can now be null
- Updates the logic to handle cases where no container is provided by using a synthetic viewport rectangle
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/react-utils/src/useSticky.ts | Updates sticky positioning logic to use viewport dimensions as fallback instead of document.body |
| .changeset/rare-dancers-beam.md | Documents the change for release notes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
5a8aeef to
3736fd1
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
229da2d to
32bc988
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
32bc988 to
728d858
Compare
Previously, element used to determine stickiness was the
document.body. This worked on sites whosebodywas styled in an opinionated manner. This has been replaced with a representation ofViewportinstead, meaning the dimensions of your browser window over arbitrarybodydimensions, which can overflow / underflow theViewport.