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 double start when activateAfterLongPress is used #2628

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Changes from 2 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
9 changes: 9 additions & 0 deletions apple/RNGestureHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,15 @@ - (void)sendEventsInState:(RNGestureHandlerState)state
return;
}

// When activating a handler under custom conditions (like activateAfterLongPress) recognizers don't respect
// manually changing their state, if we send a custom event in state ACTIVE and the recognizer will later update its
// state, we will end up sending ACTIVE->BEGAN and BEGAN->ACTIVE chain. To prevent this, we simply detect the first
// weird state change and stop it (then we don't update _lastState), so the second call ends up without state change
// and is fine.
j-piasecki marked this conversation as resolved.
Show resolved Hide resolved
if (state == RNGestureHandlerStateBegan && _lastState == RNGestureHandlerStateActive) {
return;
}

if (state == RNGestureHandlerStateActive) {
// Generate a unique coalescing-key each time the gesture-handler becomes active. All events will have
// the same coalescing-key allowing RCTEventDispatcher to coalesce RNGestureHandlerEvents when events are
Expand Down
Loading