Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,17 @@ class GestureHandlerOrchestrator(
}

/**
* Cancels all handlers created using API v1 and v2
* Cancels the handlers that lose to a native view taking the touch lock: the ones created using
* API v1 and v2, and the [NativeViewGestureHandler] a button manages for itself.
*
* The button's handler is attached with [GestureHandler.ACTION_TYPE_NONE] - it dispatches its
* events natively rather than through an action - so an action type check alone leaves it
* running. It has to be cancelled here as well, or a touch that a native view claims still ends
* the button handler and fires a press. The root view's own handler shares that action type and
* must keep running, hence the type check rather than a plain [GestureHandler.ACTION_TYPE_NONE]
* one.
Comment on lines +375 to +377
*/
fun cancelAllLegacyHandlers() {
fun cancelHandlersLosingToNativeGesture() {
val handlersToProcess = obtainHandlerList()
handlersToProcess.addAll(gestureHandlers)

Expand All @@ -377,7 +385,8 @@ class GestureHandlerOrchestrator(
if (it.actionType == GestureHandler.ACTION_TYPE_JS_FUNCTION_OLD_API ||
it.actionType == GestureHandler.ACTION_TYPE_JS_FUNCTION_NEW_API ||
it.actionType == GestureHandler.ACTION_TYPE_REANIMATED_WORKLET ||
it.actionType == GestureHandler.ACTION_TYPE_NATIVE_ANIMATED_EVENT
it.actionType == GestureHandler.ACTION_TYPE_NATIVE_ANIMATED_EVENT ||
(it is NativeViewGestureHandler && it.actionType == GestureHandler.ACTION_TYPE_NONE)
Comment on lines +388 to +389

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will regress #4367 - requestDisallowInterceptTouchEvent would cancel all buttons globally again, instead of being scoped to the relevant subtree.

@m-bert is exploring other approaches to this problem in #4441

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I close this PR in favor of #4441

) {
it.cancel()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
if (orchestrator != null && !passingTouch) {
// if we are in the process of delivering touch events via GH orchestrator, we don't want to
// treat it as a native gesture capturing the lock
orchestrator.cancelAllLegacyHandlers()
orchestrator.cancelHandlersLosingToNativeGesture()
}
}

Expand Down
Loading