Skip to content

Commit ef531eb

Browse files
coadoj-piasecki
andauthored
[Android] Fix ScrollView momentum after JS responder cancellation (#4203)
## Description This removes the responder-release callback that cleared shouldIntercept as soon as a Gesture Handler finished. Clearing interception during the same terminal `ACTION_UP` dispatch allowed the event to fall through to the regular `React/native` dispatch path after it had already been forwarded by `NativeViewGestureHandler`. For wrapped ScrollViews, that extra release event could prevent native fling from starting, breaking scroll momentum. The root view already resets `shouldIntercept` when the next touch stream begins, so keeping interception through the end of the current stream preserves the expected scroll behavior without leaving future touches blocked. ## Test plan Checked ScrollView and `cancelsJSResponder` example <!-- Describe how did you test this change here. --> --------- Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>
1 parent fba4dcc commit ef531eb

3 files changed

Lines changed: 0 additions & 12 deletions

File tree

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,6 @@ class GestureHandlerOrchestrator(
145145
fun onHandlerStateChange(handler: GestureHandler, newState: Int, prevState: Int) {
146146
handlingChangeSemaphore += 1
147147

148-
if (isFinished(newState) && handler.isActive && handler.cancelsJSResponder) {
149-
// Check if there are any other active handlers that still request the JS responder to be cancelled.
150-
if (gestureHandlers.none { it !== handler && it.isActive && it.cancelsJSResponder }) {
151-
onJSResponderCancelListener?.onCancelJSResponderReleased(handler)
152-
}
153-
}
154-
155148
if (isFinished(newState)) {
156149
// We have to loop through copy in order to avoid modifying collection
157150
// while iterating over its elements

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/OnJSResponderCancelListener.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ package com.swmansion.gesturehandler.core
22

33
interface OnJSResponderCancelListener {
44
fun onCancelJSResponderRequested(handler: GestureHandler)
5-
fun onCancelJSResponderReleased(handler: GestureHandler)
65
}

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
4444
}
4545
event.recycle()
4646
}
47-
48-
override fun onCancelJSResponderReleased(handler: GestureHandler) {
49-
shouldIntercept = false
50-
}
5147
}
5248
orchestrator = GestureHandlerOrchestrator(
5349
wrappedView,

0 commit comments

Comments
 (0)