Skip to content

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

Open
Dashice wants to merge 3 commits intomainfrom
fix/use-sticky-viewport-container
Open

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

Conversation

@Dashice
Copy link
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

changeset-bot bot commented Jun 23, 2025

🦋 Changeset detected

Latest commit: 58400ad

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

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 Feb 26, 2026 0:59am

Request Review

@codecov
Copy link

codecov bot commented Jun 23, 2025

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/react-utils/src/useSticky.ts 0.00% 3 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

@@           Coverage Diff           @@
##             main     #553   +/-   ##
=======================================
  Coverage   67.86%   67.86%           
=======================================
  Files          63       63           
  Lines         974      974           
  Branches      246      246           
=======================================
  Hits          661      661           
  Misses        254      254           
  Partials       59       59           
Files with missing lines Coverage Δ
packages/react-utils/src/useSticky.ts 0.00% <0.00%> (ø)
🚀 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.

Copy link
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

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.

@adamsoderstrom adamsoderstrom force-pushed the fix/use-sticky-viewport-container branch from 5a8aeef to 3736fd1 Compare February 26, 2026 12:53
refactor(react-utils): `useSticky` - use `DOMRect` for `pRect`
Copy link

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.

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