Repository navigation
Conversation
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>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
On iOS a scroll view does not scroll while one of its ancestors is the JavaScript responder:
RCTScrollViewComponentViewanswers NO fromtouchesShouldCancelInContentView:, and aUIScrollViewthat may not cancel its content's touches does not begin dragging. This is meant for a gesture that JavaScript owns, such as aPanResponderaround a list.setIsJSResponderalso says whether the responder blocks native responders, which is the valueonResponderGrantreturns.PanResponderblocks by default (onShouldBlockNativeResponder);Pressabilityblocks only whenblockNativeResponderis set.RCTMountingManagerdropped that argument, so every responder blocked. A scroll view inside aPressableor aTouchablecould 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:JSResponderHandleronly 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, theScrollViewtakes the responder (onScrollShouldSetResponder), and the press is terminated, as it is for aPressableinside a scroll view.This changes behavior that Fabric on iOS has had since
setIsJSResponderwas added: a view that takes the responder through the raw responder props and does not returntruefromonResponderGrantno longer stops the scroll views inside it. Such a view that tracks a drag withonResponderMovenow getsonResponderTerminatewhen a scroll view inside it begins dragging; returningtruefromonResponderGrantkeeps the old behavior. APanResponderstill stops them, unlessonShouldBlockNativeResponderreturnsfalse.RCTComponentViewProtocolgainsblocksNativeResponderandsetBlocksNativeResponder:, with default implementations inUIView+ComponentViewProtocol, and this PR updates the fourReactApple*Cxx.apisnapshots underscripts/cxx-api/api-snapshotsto match.Changelog:
[IOS] [CHANGED] - A JS responder now stops the ScrollViews inside it only when it blocks native responders (
onResponderGrantreturnstrue), so a ScrollView inside a Pressable can be scrolledTest Plan:
Added
testAncestorJSResponderDisablesScrollingOnlyWhileItBlocksNativeRespondertoReact/Tests/Mounting/RCTScrollViewComponentViewTests.mm. It drives-[RCTMountingManager setIsJSResponder:blockNativeResponder:forShadowView:]for an ancestor of a scroll view and readstouchesShouldCancelInContentView:. Its first assertion (responder that does not block) fails without the change toRCTMountingManagerandRCTScrollViewComponentView.Ran:
Run on this base (2026-11-28, Xcode 27.1, iOS 27.0 simulator):
RCTScrollViewComponentViewTestson this branch: 13 tests, 0 failures.mainand the test kept:testAncestorJSResponderDisablesScrollingOnlyWhileItBlocksNativeResponderfails at the first assertion (touchesShouldCancelInContentView:is false under a responder that does not block).React/Testsbelongs to theReact-RCTFabricpod'sTeststest spec, which RNTester's Podfile does not install. To run it, I added:testspecs => ['Tests']to theReact-RCTFabricpod inscripts/cocoapods/fabric.rb, narrowed the test spec'ssource_filesto this test file, and added an empty Swift file to the test spec so the bundle links the Swift runtime thatRCTSwiftUIneeds. None of that is part of this change. With the whole test spec,RCTSelectableParagraphComponentViewTests.mmdoes not compile in open source (react/renderer/element/ComponentBuilder.hnot found).Not run: the hand check below.
To check by hand in RNTester (Playground), render:
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 logspress. Wrapping the list in aViewwith{...PanResponder.create({onStartShouldSetPanResponder: () => true}).panHandlers}instead still keeps the list from scrolling, before and after.🤖 Generated with Claude Code