Skip to content

[iOS] Make scrollToEnd include adjusted content inset#57523

Open
eliotgevers wants to merge 1 commit into
react:mainfrom
eliotgevers:agent/scroll-to-end-adjusted-inset
Open

[iOS] Make scrollToEnd include adjusted content inset#57523
eliotgevers wants to merge 1 commit into
react:mainfrom
eliotgevers:agent/scroll-to-end-adjusted-inset

Conversation

@eliotgevers

Copy link
Copy Markdown

Summary:

Fixes #57522.

ScrollView.scrollToEnd() currently computes its iOS Fabric endpoint from UIScrollView.contentInset. When UIKit supplies safe-area or bar adjustments through adjustedContentInset, the command stops before the same endpoint a user can reach by dragging.

This change uses adjustedContentInset when constructing the vertical or horizontal end target. It also adds a focused native regression test with a 100-point viewport, 200-point content height, zero raw inset, and a 20-point adjusted bottom inset. scrollToEnd() must finish at offset 120.

This is related to, but distinct from, #56189. That PR moves general scrollTo clamping into scrollToOffset and uses adjustedContentInset; however, scrollToEnd() still constructs an already-valid but too-small target from raw contentInset, so the later clamp does not increase it.

The public reproduction starts from the official React Native reproducer template and does not use Expo, navigation, a keyboard, or an explicit contentInset:

https://github.com/eliotgevers/react-native-scroll-to-end-adjusted-inset-repro

Changelog:

[IOS] [FIXED] - Make ScrollView.scrollToEnd() include system-adjusted content insets

Test Plan:

Tested on an iPhone 17 Pro Max simulator running iOS 26.5 with React Native compiled from source.

Native implementation scrollToEnd() scrollTo({y: 9999}) Manual end
Stock React Native 0.86.0 364 364 398
#56189 effective Fabric logic 364 398 398
#56189 logic plus this change 398 398 398

The 34-point difference equals the simulator's adjusted bottom safe-area inset.

Stock React Native 0.86.0 Patched native source
Stock React Native scrollToEnd stops at offset 364 Patched React Native scrollToEnd reaches offset 398

Focused RNTester regression test:

Test Suite 'RCTScrollViewComponentViewTests' passed.
Executed 1 test, with 0 failures in 0.034 seconds.
** TEST SUCCEEDED **

The test was run through RNTesterPods.xcworkspace, scheme RNTester, with:

xcodebuild test \
  -workspace RNTesterPods.xcworkspace \
  -scheme RNTester \
  -sdk iphonesimulator \
  -destination 'platform=iOS Simulator,id=<simulator-id>' \
  -only-testing:RNTesterUnitTests/RCTScrollViewComponentViewTests
Local RNTester harness note

Current main locally hit an unrelated compile error in RCTTurboModuleArrayBufferTests.mm (detail::OwnedBytesBuffer is not declared by that file's imports). I temporarily excluded that existing test source from the local focused build so this new test could compile and run. That exclusion is not included in this PR.

@meta-cla

meta-cla Bot commented Jul 12, 2026

Copy link
Copy Markdown

Hi @eliotgevers!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@eliotgevers eliotgevers marked this pull request as ready for review July 12, 2026 06:03
@meta-cla

meta-cla Bot commented Jul 12, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 12, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS][Fabric] ScrollView.scrollToEnd ignores adjustedContentInset

1 participant