Skip to content

Let iOS scroll views scroll inside a non-blocking JS responder - #60367

Draft
ide wants to merge 1 commit into
react:mainfrom
expo:@ide/ios-block-native-responder
Draft

ide wants to merge 1 commit into
react:mainfrom
expo:@ide/ios-block-native-responder

Conversation

@ide

@ide ide commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary:

On iOS a scroll view does not scroll while one of its ancestors is the JavaScript responder: RCTScrollViewComponentView answers NO from touchesShouldCancelInContentView:, and a UIScrollView that may not cancel its content's touches does not begin dragging. This is meant for a gesture that JavaScript owns, such as a PanResponder around a list.

setIsJSResponder also says whether the responder blocks native responders, which is the value onResponderGrant returns. PanResponder blocks by default (onShouldBlockNativeResponder); Pressability blocks only when blockNativeResponder is set. RCTMountingManager dropped that argument, so every responder blocked. A scroll view inside a Pressable or a Touchable could not be dragged from content that does not itself take the responder, such as plain text, because the press had made the ancestor the responder. On Android the same tree scrolls: JSResponderHandler only acts on the flag, and only towards the responder's parents.

This change passes the argument on to the component view as blocksNativeResponder, and the scroll view stops only for an ancestor that blocks. The scroll then begins, the ScrollView takes the responder (onScrollShouldSetResponder), and the press is terminated, as it is for a Pressable inside a scroll view.

This changes behavior that Fabric on iOS has had since setIsJSResponder was added: a view that takes the responder through the raw responder props and does not return true from onResponderGrant no longer stops the scroll views inside it. Such a view that tracks a drag with onResponderMove now gets onResponderTerminate when a scroll view inside it begins dragging; returning true from onResponderGrant keeps the old behavior. A PanResponder still stops them, unless onShouldBlockNativeResponder returns false.

RCTComponentViewProtocol gains blocksNativeResponder and setBlocksNativeResponder:, with default implementations in UIView+ComponentViewProtocol, and this PR updates the four ReactApple*Cxx.api snapshots under scripts/cxx-api/api-snapshots to match.

Changelog:

[IOS] [CHANGED] - A JS responder now stops the ScrollViews inside it only when it blocks native responders (onResponderGrant returns true), so a ScrollView inside a Pressable can be scrolled

Test Plan:

Added testAncestorJSResponderDisablesScrollingOnlyWhileItBlocksNativeResponder to React/Tests/Mounting/RCTScrollViewComponentViewTests.mm. It drives -[RCTMountingManager setIsJSResponder:blockNativeResponder:forShadowView:] for an ancestor of a scroll view and reads touchesShouldCancelInContentView:. Its first assertion (responder that does not block) fails without the change to RCTMountingManager and RCTScrollViewComponentView.

Ran:

node scripts/clang-format.js --check <the 7 changed files>   # exit 0
git diff --check                                             # clean

Run on this base (2026-11-28, Xcode 27.1, iOS 27.0 simulator):

xcodebuild -workspace packages/rn-tester/RNTesterPods.xcworkspace -scheme RNTester -configuration Debug \
  -destination 'generic/platform=iOS Simulator' ARCHS=arm64 ONLY_ACTIVE_ARCH=YES CODE_SIGNING_ALLOWED=NO build
xcodebuild test -workspace packages/rn-tester/RNTesterPods.xcworkspace -scheme React-RCTFabric-Unit-Tests \
  -destination 'platform=iOS Simulator,id=<iPhone 18 Pro>'
  • RNTester builds.
  • RCTScrollViewComponentViewTests on this branch: 13 tests, 0 failures.
  • With the source changes from main and the test kept: testAncestorJSResponderDisablesScrollingOnlyWhileItBlocksNativeResponder fails at the first assertion (touchesShouldCancelInContentView: is false under a responder that does not block).

React/Tests belongs to the React-RCTFabric pod's Tests test spec, which RNTester's Podfile does not install. To run it, I added :testspecs => ['Tests'] to the React-RCTFabric pod in scripts/cocoapods/fabric.rb, narrowed the test spec's source_files to this test file, and added an empty Swift file to the test spec so the bundle links the Swift runtime that RCTSwiftUI needs. None of that is part of this change. With the whole test spec, RCTSelectableParagraphComponentViewTests.mm does not compile in open source (react/renderer/element/ComponentBuilder.h not found).

Not run: the hand check below.

To check by hand in RNTester (Playground), render:

<Pressable onPress={() => console.log('press')} style={{height: 300}}>
  <ScrollView>
    {Array.from({length: 40}, (_, i) => (
      <Text key={i} style={{padding: 12}}>Row {i}</Text>
    ))}
  </ScrollView>
</Pressable>

Drag a row. Before: the list does not move and releasing logs press. After: the list scrolls and no press is logged; a tap still logs press. Wrapping the list in a View with {...PanResponder.create({onStartShouldSetPanResponder: () => true}).panHandlers} instead still keeps the list from scrolling, before and after.

🤖 Generated with Claude Code

On iOS a scroll view does not scroll while one of its ancestors is the
JavaScript responder: `RCTScrollViewComponentView` answers NO from
`touchesShouldCancelInContentView:`, and a `UIScrollView` that may not
cancel its content's touches does not begin dragging. This is meant for
a gesture that JavaScript owns, such as a `PanResponder` around a list.

`setIsJSResponder` also says whether the responder blocks native
responders, which is the value `onResponderGrant` returns. `PanResponder`
blocks by default; `Pressability` blocks only when `blockNativeResponder`
is set. `RCTMountingManager` dropped that argument, so every responder
blocked. A scroll view inside a `Pressable` or a `Touchable` could not
be dragged from content that does not itself take the responder, such as
plain text, because the press had made the ancestor the responder. On
Android the same tree scrolls.

Pass the argument on to the component view as `blocksNativeResponder`,
and have the scroll view stop only for an ancestor that blocks. The
scroll then begins, the `ScrollView` takes the responder, and the press
is terminated, as it is for a `Pressable` inside a scroll view.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Nov 28, 2026
@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 28, 2026

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. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant