Skip to content

Share iOS cancelled-touch bookkeeping and test the pointer cancel - #60500

Open
ide wants to merge 1 commit into
react:mainfrom
expo:@ide/ios-touch-cancel-bookkeeping
Open

ide wants to merge 1 commit into
react:mainfrom
expo:@ide/ios-touch-cancel-bookkeeping

Conversation

@ide

@ide ide commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary:

#60367 lets a scroll view inside a ScrollView that is the JavaScript responder cancel the touches that began inside it. RCTSurfaceTouchHandler and RCTSurfacePointerHandler each kept their own copy of the bookkeeping for those cancelled touches, and only the touch handler's cancel had a test. chrfalch's review of #60367 suggested sharing the bookkeeping and testing the pointer handler (#60367 (review)).

This change moves the bookkeeping into RCTCancelledTouches, a C++ class both handlers hold. It is declared in RCTCancelledTouches+Internal.h, which the C++ API snapshots leave out. Behavior doesn't change.

Changelog:

[Internal] - Share the cancelled-touch bookkeeping of the iOS touch and pointer handlers, and test the pointer handler's cancel

Test Plan:

RCTScrollViewComponentViewTests gains testDragUnderScrollViewJSResponderCancelsOnlyThePointersInsideTheScrollView. It checks that a drag cancels only the pointers inside the inner scroll view, that the cancelled touch's later events are dropped, that a touch beginning inside waits until the cancelled one ends, and that reset clears the state. It and the existing touch-handler test pass before and after the move, and breaking each part of the bookkeeping makes one of them fail. I didn't run the change in RNTester.

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

RNTester's Podfile doesn't install the React-RCTFabric Tests spec, so open-source CI doesn't run these tests. yarn format-check-cpp passes.

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Visual regression

No visual differences at d73f6d575d97.

android: no capture

@ide
ide marked this pull request as ready for review December 3, 2026 03:07
Summary:

react#60367 lets a scroll view inside a `ScrollView` that is the JavaScript responder cancel the touches that began inside it. `RCTSurfaceTouchHandler` and `RCTSurfacePointerHandler` each kept their own copy of the bookkeeping for those cancelled touches, and only the touch handler's cancel had a test. chrfalch's review of react#60367 suggested sharing the bookkeeping and testing the pointer handler (react#60367 (review)).

This change moves the bookkeeping into `RCTCancelledTouches`, a C++ class both handlers hold. It is declared in `RCTCancelledTouches+Internal.h`, which the C++ API snapshots leave out. Behavior doesn't change.

Changelog:

[Internal] - Share the cancelled-touch bookkeeping of the iOS touch and pointer handlers, and test the pointer handler's cancel

Test Plan:

`RCTScrollViewComponentViewTests` gains `testDragUnderScrollViewJSResponderCancelsOnlyThePointersInsideTheScrollView`. It checks that a drag cancels only the pointers inside the inner scroll view, that the cancelled touch's later events are dropped, that a touch beginning inside waits until the cancelled one ends, and that `reset` clears the state. It and the existing touch-handler test pass before and after the move, and breaking each part of the bookkeeping makes one of them fail. I didn't run the change in RNTester.

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

RNTester's Podfile doesn't install the `React-RCTFabric` `Tests` spec, so open-source CI doesn't run these tests. `yarn format-check-cpp` passes.

Signed-off-by: James Ide <ide@expo.dev>
@ide
ide force-pushed the @ide/ios-touch-cancel-bookkeeping branch from 78c79b2 to d73f6d5 Compare December 3, 2026 13:31
@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 Dec 3, 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

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