Skip to content

docs: explain where scrollTo's final offset is delivered - #1942

Closed
mdjastrzebski wants to merge 1 commit into
callstack:mainfrom
mdjastrzebski:docs/scroll-to-final-offset
Closed

mdjastrzebski wants to merge 1 commit into
callstack:mainfrom
mdjastrzebski:docs/scroll-to-final-offset

Conversation

@mdjastrzebski

Copy link
Copy Markdown
Member

Summary

user.scrollTo() doesn't emit a scroll event for the last drag step, which matches native ScrollView. So a drag-only scroll such as { y: 100 } calls onScroll with 25, 50 and 75, and only onScrollEndDrag receives 100. This catches out anyone testing UI driven by onScroll (sticky headers, "scroll to top" buttons, paging dots). Their assertions fail with no obvious reason, or they change their component to work around the test.

This adds a "Final scroll offset" section to the scrollTo() API docs. It:

  • says the target offset of a drag-only scroll reaches only scrollEndDrag, never onScroll;
  • says that with momentum, the final offset reaches both the last scroll event and momentumScrollEnd;
  • explains how to get the target offset to onScroll by adding a momentum part, e.g. { y: 50, momentumY: 100 }, or by handling onScrollEndDrag / onMomentumScrollEnd in the component.

Changed files:

  • website/docs/14.x/docs/api/events/user-event.mdx (source)
  • docs/api/user-event.md (regenerated with yarn docs:generate)

Test plan

  • yarn jest src/user-event/scroll: 24 tests passed. Existing tests in scroll-to.test.tsx already pin down the documented event sequences (drag-only { y: 100 } -> scroll 25/50/75, scrollEndDrag 100; with momentum, the last scroll and momentumScrollEnd both carry the final offset).
  • yarn docs:generate: regenerated docs/api/user-event.md.
  • yarn format:check: passes.

Known gaps:

  • Did not run the full yarn validate (docs-only change).
  • Only the 14.x docs are updated. The 12.x and 13.x docs describe the same behavior but are unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LRqiwDiwMREi1PjUC5typh


Generated by Claude Code

@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.36%. Comparing base (d33cb7e) to head (e53ac9d).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1942      +/-   ##
==========================================
- Coverage   98.48%   98.36%   -0.12%     
==========================================
  Files          84       87       +3     
  Lines        1581     1714     +133     
  Branches      432      463      +31     
==========================================
+ Hits         1557     1686     +129     
- Misses         24       26       +2     
- Partials        0        2       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

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.

2 participants