File tree Expand file tree Collapse file tree
packages/react-native-gesture-handler/src/components/Pressable Expand file tree Collapse file tree Original file line number Diff line number Diff 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 } ) ,
Original file line number Diff line number Diff 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
1213function getAndroidStatesConfig (
You can’t perform that action at this time.
0 commit comments