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 gets NO from that method stops 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: the value the responder's onResponderGrant returns. PanResponder blocks by default (onShouldBlockNativeResponder); Pressability blocks only when blockNativeResponder is set. RCTMountingManager dropped that argument, so every responder blocked, and 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. On Android, JSResponderHandler stops the responder's ancestors from intercepting touches only when the responder blocks; the same tree was not checked on an Android device.

This change passes the argument 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 for a Pressable inside a scroll view.

Behavior change: 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. If it tracks a drag with onResponderMove, a scroll view inside it can now begin dragging, and the view gets onResponderTerminate unless its onResponderTerminationRequest returns false. Returning true from onResponderGrant keeps the old behavior. A PanResponder still stops them unless onShouldBlockNativeResponder returns false; that option, documented as Android-only, now works on iOS too.

RCTComponentViewProtocol gains blocksNativeResponder and setBlocksNativeResponder:, with defaults in UIView+ComponentViewProtocol. Scroll views no longer read isJSResponder, so a component view that implements setIsJSResponder: without inheriting from RCTViewComponentView stops blocking them unless it also implements blocksNativeResponder. The four ReactApple*Cxx.api snapshots are updated.

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:

testAncestorJSResponderDisablesScrollingOnlyWhileItBlocksNativeResponder in RCTScrollViewComponentViewTests is new. Without the source changes it fails at its first assertion: touchesShouldCancelInContentView: is false under a responder that does not block. Run with Xcode 27.1 on an iOS 27.0 simulator; RNTester builds:

xcodebuild test -workspace packages/rn-tester/RNTesterPods.xcworkspace -scheme React-RCTFabric-Unit-Tests \
  -destination 'platform=iOS Simulator,id=<iPhone 18 Pro>'

RNTester's Podfile does not install the React-RCTFabric Tests test spec. To run it (locally, not in this change): add :testspecs => ['Tests'] to that pod in scripts/cocoapods/fabric.rb, narrow the test spec's source_files to this test file (RCTSelectableParagraphComponentViewTests.mm does not compile in open source), and add an empty Swift file to it so the bundle links the Swift runtime RCTSwiftUI needs.

Not checked 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 keeps the list from scrolling, before and after.

@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
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, `JSResponderHandler` stops the responder's ancestors from
intercepting touches only when the responder blocks.

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>
@ide
ide force-pushed the @ide/ios-block-native-responder branch from db36716 to 1d6d309 Compare November 29, 2026 12:02

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