Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handlers coming back from being cancelled #2704

Merged
merged 3 commits into from
Feb 5, 2024
Merged
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 @@ -174,9 +174,19 @@ class GestureHandlerOrchestrator(
}
cleanupAwaitingHandlers()

// Dispatch state change event if handler is no longer in the active state we should also
// trigger END state change and UNDETERMINED state change if necessary
// At this point the waiting handler is allowed to activate, so we need to send BEGAN -> ACTIVE event
// as it wasn't sent before. If handler has finished recognizing the gesture before it was allowed to
// activate, we also need to send ACTIVE -> END and END -> UNDETERMINED events, as it was blocked from
// sending events while waiting.
// There is one catch though - if the handler failed or was cancelled while waiting, relevant event has
// already been sent. The following chain would result in artificially activating that handler after the
// failure logic was ran and we don't want to do that.
if (currentState == GestureHandler.STATE_FAILED || currentState == GestureHandler.STATE_CANCELLED) {
return
}

handler.dispatchStateChange(GestureHandler.STATE_ACTIVE, GestureHandler.STATE_BEGAN)

if (currentState != GestureHandler.STATE_ACTIVE) {
handler.dispatchStateChange(GestureHandler.STATE_END, GestureHandler.STATE_ACTIVE)
if (currentState != GestureHandler.STATE_END) {
Expand Down
Loading