Skip to content

feat: add useScrollAnchor with an interactive demo - #8753

Draft
tay1orjones wants to merge 2 commits into
mainfrom
tay1orjones-safari-scroll-preservation
Draft

tay1orjones wants to merge 2 commits into
mainfrom
tay1orjones-safari-scroll-preservation

Conversation

@tay1orjones

@tay1orjones tay1orjones commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes github/primer#6306

Keep the comment you're reading in place when earlier content loads, including in browsers without native scroll anchoring. useScrollAnchor is opt-in, so existing consumers are unchanged.

Changelog

New

  • useScrollAnchor({containerRef, anchorRef}) preserves an element's viewport position as its container changes.
  • An interactive Storybook demo and hook API documentation.

Changed

Removed

Rollout strategy

  • No changes needed in github/github-ui
  • Needs changes in github/github-ui
  • Ships with feature flag(s)
  • Not sure
  • None

Adoption plan: IssueTimeline supplies the timeline container ref and a visible comment ref, owns anchor selection, and reconciles its existing Safari workaround. Upgrading Primer alone won't change timeline behavior.

Testing & Reviewing

Open Hooks/useScrollAnchor → Scroll Anchor. Scroll to the highlighted comment, load earlier comments, and toggle the hook to compare. Native scroll anchoring is disabled in the demo to isolate the hook's behavior. Only window scrolling is supported.

Focused hook tests and TypeScript checking pass. Real Safari scrolling and hash-navigation behavior still need verification. Incomplete local dependencies block the build, linting, and Storybook preview.

Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 64f72b4

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

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

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

@github-actions github-actions Bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch was successfully deployed

2 active deployments
storybook-preview-8753 — dd1192ce Deployed Nov 13, 2026 by github-actions[bot]
github-pages — dd1192ce Deployed Nov 13, 2026 by tay1orjones via deploy-preview #34297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant