diff --git a/packages/react-native-gesture-handler/src/v3/components/StatefulPressable.tsx b/packages/react-native-gesture-handler/src/v3/components/StatefulPressable.tsx index 170ed38526..765c1b25de 100644 --- a/packages/react-native-gesture-handler/src/v3/components/StatefulPressable.tsx +++ b/packages/react-native-gesture-handler/src/v3/components/StatefulPressable.tsx @@ -125,7 +125,6 @@ const StatefulPressable = (props: PressableProps) => { if (longPressTimeoutRef.current) { clearTimeout(longPressTimeoutRef.current); longPressTimeoutRef.current = null; - isOnPressAllowed.current = true; } }, []); @@ -141,6 +140,7 @@ const StatefulPressable = (props: PressableProps) => { if (onLongPress) { cancelLongPress(); longPressTimeoutRef.current = setTimeout(() => { + longPressTimeoutRef.current = null; isOnPressAllowed.current = false; onLongPress(event); }, delayLongPress ?? DEFAULT_LONG_PRESS_DURATION); @@ -188,6 +188,7 @@ const StatefulPressable = (props: PressableProps) => { } isCurrentlyPressed.current = true; + isOnPressAllowed.current = true; pressInEventRef.current = event; if (unstable_pressDelay) { pressDelayTimeoutRef.current = setTimeout(() => { @@ -311,6 +312,11 @@ const StatefulPressable = (props: PressableProps) => { pressableEvent ); }, + onTouchesUp: () => { + // The button may still be waiting for another gesture; a long press + // must not fire after the finger lifted + cancelLongPress(); + }, onTouchesCancel: (event) => { const pressableEvent = gestureTouchToPressableEvent(event); stateMachine.reset();