Skip to content
Merged
Show file tree
Hide file tree
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 @@ -270,9 +270,13 @@ const Pressable = (props: PressableProps) => {
stateMachine.reset();
handlePressOut(pressableEvent, false);
})
.onFinalize(() => {
.onFinalize((_event, success) => {
if (Platform.OS === 'web') {
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
if (success) {
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
} else {
stateMachine.handleEvent(StateMachineEvent.CANCEL);
}
handleFinalize();
}
}),
Expand Down Expand Up @@ -301,11 +305,15 @@ const Pressable = (props: PressableProps) => {
stateMachine.handleEvent(StateMachineEvent.NATIVE_START);
}
})
.onFinalize(() => {
.onFinalize((_event, success) => {
if (Platform.OS !== 'web') {
// On Web we use LongPress().onFinalize() instead of Native().onFinalize(),
// as Native cancels on mouse move, and LongPress does not.
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
if (success) {
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
} else {
stateMachine.handleEvent(StateMachineEvent.CANCEL);
}
handleFinalize();
}
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum StateMachineEvent {
NATIVE_START = 'nativeStart',
FINALIZE = 'finalize',
LONG_PRESS_TOUCHES_DOWN = 'longPressTouchesDown',
CANCEL = 'cancel',
}

function getAndroidStatesConfig(
Expand Down
Loading