Repository navigation
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Schedule and process intercepted-view cancellation packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt, packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt |
The root helper schedules cancellation when interception starts and removes the previous dispatch-time transition check. After gesture handlers receive an event, the orchestrator performs pending cancellation, then updates pointer tracking. Pointer-up removes only the lifted pointer; up and cancel clear all tracked points. |
Sequence Diagram(s)
sequenceDiagram
participant RNGestureHandlerRootHelper
participant GestureHandlerOrchestrator
participant GestureHandlers
participant InterceptedViews
RNGestureHandlerRootHelper->>GestureHandlerOrchestrator: Schedule cancellation when interception starts
GestureHandlerOrchestrator->>GestureHandlers: Deliver touch event
GestureHandlerOrchestrator->>InterceptedViews: Cancel touches at tracked pointer positions
GestureHandlerOrchestrator->>GestureHandlerOrchestrator: Update pointer tracking after cancellation
Possibly related issues
- [Android] A quick tap on a button in a scroll view also presses React Native's Pressable around it #4626 — Describes a quick tap in a
ScrollViewwhere aPressableremains pressed because cancellation arrives after the root view ends the touch. This change moves cancellation into event processing before pointer cleanup.
Possibly related PRs
- software-mansion/react-native-gesture-handler#4639 — Changes Android
StatefulPressablehandling when its native gesture receives cancellation. This PR changes when intercepted native views receiveACTION_CANCEL.
Suggested reviewers: j-piasecki, m-bert
Priority:
Merge Risk: 
Minimal · up to 02ee3
-
The change appears ready to merge after normal checks; the reviewed paths preserve touch cancellation timing and active native scrolling.
Pre-merge checks: 
3
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
🔵 Needs a closer look
The reentrancy-sensitive Android dispatch changes warrant human validation, especially because the reported regression harness is not included in the PR.
No open issues 🎉
What changed in this PR
This PR fixes delayed text selection after an intercepted short tap on Android by cancelling native touches before gesture cleanup removes the state needed for cancellation.
Changes:
- Moves native-touch cancellation into orchestrator dispatch, keeping interception guards active during cancellation.
- Defers pointer-position cleanup until after cancellation, while preserving native-handler ownership.
| File | Description |
|---|---|
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt | Registers a callback to cancel native touches inside orchestrator dispatch. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt | Invokes the callback before terminal-event cleanup. |
Review effort: Balanced
|
I've published the regression tests and run instructions on a separate test branch. The branch contains two commits so the same suite can be run against both versions:
Coverage includes terminal-event cancellation, native-handler ownership, and reentrant |
|
Hi @huamurui! Thank you for spotting this issue and submitting a fix! I took the liberty of introducing some changes - could you please verify them and confirm that the PR still works? |
|
Thanks for the changes! I tested the updated PR on my Android device and can confirm it still fixes the issue. Long-press text selection and scrolling also work as expected. |
Description
A short tap on a plain React Native
Text selectablecan select a word after the finger has lifted when a Tap gesture interceptsACTION_UP.This change runs native-touch cancellation before pointer coordinates and finished-handler state are cleared. It preserves native ownership and keeps cancellation inside touch dispatch to prevent reentrant interception requests from cancelling the winning gesture.
Reproduction
Environment: RNGH 3.4.0 · RN 0.88.0 · Fabric/Hermes · Android 16 (vivo V2509A).
Minimal v3 reproduction
Set
enabled: falseon the Tap for a control.Test plan
git diff --checkpass.