Skip to content

[iOS] Keep a ScrollView's overscroll when its frame changes during a drag - #60084

Open
jkasprzyk17 wants to merge 1 commit into
react:mainfrom
jkasprzyk17:fix/ios-scrollview-frame-change-overscroll
Open

jkasprzyk17 wants to merge 1 commit into
react:mainfrom
jkasprzyk17:fix/ios-scrollview-frame-change-overscroll

Conversation

@jkasprzyk17

@jkasprzyk17 jkasprzyk17 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Fixes #59993.

On iOS (New Architecture), when a ScrollView's frame changes while a finger holds its content past an edge, the content snaps to the edge. The next pan update restores only about half of the pull. In a layout that resizes the scroll view on every frame, for example one that follows the keyboard while keyboardDismissMode="interactive" drags it, the pull keeps falling behind the finger.

The write comes from UIKit. updateLayoutMetrics: sets the bounds of RCTScrollViewComponentView. Autoresizing then sets the frame of the inner RCTEnhancedScrollView, and -[UIScrollView setFrame:] clamps contentOffset to the new scrollable range. A content size change in the same situation already keeps the offset: updateState: sets contentSize inside _preserveContentOffsetIfNeededWithBlock:, which "disables programmatical changing of ScrollView's contentOffset if a touch gesture is in progress".

This change resizes the scroll view inside the same block. A frame change during a user scroll (drag and the deceleration after it) now keeps the offset, as a content size change does. Outside a user scroll, UIKit still clamps the offset as before.

Changelog:

[IOS] [FIXED] - ScrollView keeps its overscroll when its frame changes during a drag

Test Plan:

RNTester on an iOS 26.5 simulator (iPhone 17 Pro), New Architecture, Debug. The Playground ran the issue's reproducer (605fc90): a footer under the list flips between 80 and 140 every second, which resizes the ScrollView. I added an on-screen counter of "jumps", meaning an overscroll of more than 5 pt that becomes the edge in one onScroll while the finger is down. The same gesture ran before and after: pull the list ~54 pt past its top and hold for ~5 s.

Before After
Frame changes during the hold 6 6
Jumps 4 (twice, same result) 0

onScroll log (ms timestamp), before:

scroll y -54.0
flip footer (frame) 140
scroll y 0.0
scroll y -30.3
...
flip footer (frame) 80
scroll y 0.0
scroll y -16.3
...
flip footer (frame) 140
scroll y 0.0
scroll y -8.0

After:

scroll y -54.0
flip footer (frame) 140
scroll y -53.3
...
flip footer (frame) 80
scroll y -54.7
...
flip footer (frame) 140
scroll y -53.3

Regression checks, after the fix:

  • Idle, scrolled to the end, scroll view grows: the offset is still clamped to the new maximum when the frame changes (1135.7 → 1075.7), as before.
  • Hold past the bottom end: 0 jumps through 6 frame changes. The rubber-banded offset follows the moving bottom edge instead of snapping to the maximum.
  • Fling to either end, with a frame change during the deceleration or bounce: in 4 flings the list came to rest inside the scrollable range every time (0.0, 1090.3, 0.0, 1088.7 with a maximum of 1135.7). It never stayed in overscroll, and the next idle frame change clamped it as before.
  • Control (content size changes instead of the frame): 0 jumps, unchanged.
  • node scripts/clang-format.js --check on the changed file passes.

Videos, before and after (same gesture; the top line shows y, jumps and flips):

Before:

59993-before.mp4

After:

59993-after.mp4

Not tested: a physical device, a real keyboardDismissMode="interactive" keyboard flow, and the old architecture (the change is in the Fabric component view only).

…n iOS

When the frame of a ScrollView changed while a finger held its content
past an edge, UIKit's -[UIScrollView setFrame:] clamped contentOffset to
the new scrollable range, so the content snapped to the edge and the
next pan update only restored about half of the pull. A content size
change in the same situation already keeps the offset, as updateState:
sets contentSize inside _preserveContentOffsetIfNeededWithBlock:.

Resize the scroll view inside the same block, so a frame change during
a user scroll keeps the offset too. Outside a user scroll the offset is
clamped as before.

Fixes react#59993
@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 Nov 17, 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 Nov 17, 2026
@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at 1f5ea681947b.

android: no capture

This branch has not been deployed

No deployments
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: a frame change during a drag resets an overscrolled contentOffset

1 participant