Skip to content

fix(use-sticky): inconsistent fallback target#553

Open
Dashice wants to merge 4 commits into
mainfrom
fix/use-sticky-viewport-container
Open

fix(use-sticky): inconsistent fallback target#553
Dashice wants to merge 4 commits into
mainfrom
fix/use-sticky-viewport-container

Conversation

@Dashice
Copy link
Copy Markdown
Contributor

@Dashice Dashice commented Jun 23, 2025

Previously, element used to determine stickiness was the document.body. This worked on sites whose body was styled in an opinionated manner. This has been replaced with a representation of Viewport instead, meaning the dimensions of your browser window over arbitrary body dimensions, which can overflow / underflow the Viewport.

@Dashice Dashice self-assigned this Jun 23, 2025
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 23, 2025

🦋 Changeset detected

Latest commit: 728d858

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@noaignite/react-utils Patch

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

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Mar 21, 2026 5:36pm

Request Review

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 23, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/react-utils/src/useSticky.ts 66.66% 0 Missing and 1 partial ⚠️
@@            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     
Files with missing lines Coverage Δ
packages/react-utils/src/useSticky.ts 90.90% <66.66%> (+90.90%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread packages/react-utils/src/useSticky.ts Outdated
Copy link
Copy Markdown
Contributor

@maeertin maeertin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maeertin maeertin requested a review from Copilot September 24, 2025 17:18
Copy link
Copy Markdown

Copilot AI left a 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 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.body fallback with viewport-based dimensions using window.innerHeight and window.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.

Comment thread packages/react-utils/src/useSticky.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .changeset/orange-insects-hide.md
Copilot AI review requested due to automatic review settings March 20, 2026 09:34
@adamsoderstrom adamsoderstrom force-pushed the fix/use-sticky-viewport-container branch from 229da2d to 32bc988 Compare March 20, 2026 09:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .changeset/moody-peaches-help.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants