Skip to content

Commit c88c813

Browse files
committed
Merge branch 'main' into @mbert/support-82
2 parents 4fe1efc + 18be3b3 commit c88c813

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,13 @@ const Pressable = (props: PressableProps) => {
270270
stateMachine.reset();
271271
handlePressOut(pressableEvent, false);
272272
})
273-
.onFinalize(() => {
273+
.onFinalize((_event, success) => {
274274
if (Platform.OS === 'web') {
275-
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
275+
if (success) {
276+
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
277+
} else {
278+
stateMachine.handleEvent(StateMachineEvent.CANCEL);
279+
}
276280
handleFinalize();
277281
}
278282
}),
@@ -301,11 +305,15 @@ const Pressable = (props: PressableProps) => {
301305
stateMachine.handleEvent(StateMachineEvent.NATIVE_START);
302306
}
303307
})
304-
.onFinalize(() => {
308+
.onFinalize((_event, success) => {
305309
if (Platform.OS !== 'web') {
306310
// On Web we use LongPress().onFinalize() instead of Native().onFinalize(),
307311
// as Native cancels on mouse move, and LongPress does not.
308-
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
312+
if (success) {
313+
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
314+
} else {
315+
stateMachine.handleEvent(StateMachineEvent.CANCEL);
316+
}
309317
handleFinalize();
310318
}
311319
}),

packages/react-native-gesture-handler/src/components/Pressable/stateDefinitions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export enum StateMachineEvent {
77
NATIVE_START = 'nativeStart',
88
FINALIZE = 'finalize',
99
LONG_PRESS_TOUCHES_DOWN = 'longPressTouchesDown',
10+
CANCEL = 'cancel',
1011
}
1112

1213
function getAndroidStatesConfig(

0 commit comments

Comments
 (0)