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, `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
force-pushed
the
@ide/ios-block-native-responder
branch
from
November 29, 2026 12:02
db36716 to
1d6d309
Compare
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 gets NO from that method stops dragging. This is meant for a gesture that JavaScript owns, such as aPanResponderaround a list.setIsJSResponderalso says whether the responder blocks native responders: the value the responder'sonResponderGrantreturns.PanResponderblocks by default (onShouldBlockNativeResponder);Pressabilityblocks only whenblockNativeResponderis set.RCTMountingManagerdropped that argument, so every responder blocked, and a scroll view inside aPressableor aTouchablecould not be dragged from content that does not itself take the responder, such as plain text. On Android,JSResponderHandlerstops 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, theScrollViewtakes the responder (onScrollShouldSetResponder), and the press is terminated, as for aPressableinside a scroll view.Behavior change: a view that takes the responder through the raw responder props and does not return
truefromonResponderGrantno longer stops the scroll views inside it. If it tracks a drag withonResponderMove, a scroll view inside it can now begin dragging, and the view getsonResponderTerminateunless itsonResponderTerminationRequestreturnsfalse. ReturningtruefromonResponderGrantkeeps the old behavior. APanResponderstill stops them unlessonShouldBlockNativeResponderreturnsfalse; that option, documented as Android-only, now works on iOS too.RCTComponentViewProtocolgainsblocksNativeResponderandsetBlocksNativeResponder:, with defaults inUIView+ComponentViewProtocol. Scroll views no longer readisJSResponder, so a component view that implementssetIsJSResponder:without inheriting fromRCTViewComponentViewstops blocking them unless it also implementsblocksNativeResponder. The fourReactApple*Cxx.apisnapshots are updated.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:
testAncestorJSResponderDisablesScrollingOnlyWhileItBlocksNativeResponderinRCTScrollViewComponentViewTestsis 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:RNTester's Podfile does not install the
React-RCTFabricTeststest spec. To run it (locally, not in this change): add:testspecs => ['Tests']to that pod inscripts/cocoapods/fabric.rb, narrow the test spec'ssource_filesto this test file (RCTSelectableParagraphComponentViewTests.mmdoes not compile in open source), and add an empty Swift file to it so the bundle links the Swift runtimeRCTSwiftUIneeds.Not checked 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 keeps the list from scrolling, before and after.