Skip to content

Commit 8428d24

Browse files
authored
[iOS] Fix LegacyPressable not emitting onPressOut (#4121)
## Description Fixes the `LegacyPressable` on iOS getting stuck due to an unhandled `NATIVE_START` event. Updates the non-legacy implementation to also dispatch the `NATIVE_START`, which is now expected by the state machine. ## Test plan |Before|After| |-|-| |<video src="https://github.com/user-attachments/assets/7e7476f1-0d61-40d9-9c13-4f157b050bb6" />|<video src="https://github.com/user-attachments/assets/11e3b42b-e9b9-4b4f-a8cb-6dc9f20e2001" />|
1 parent 8dc38eb commit 8428d24

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ function getIosStatesConfig(
6161
eventName: StateMachineEvent.NATIVE_BEGIN,
6262
callback: handlePressIn,
6363
},
64+
{
65+
eventName: StateMachineEvent.NATIVE_START,
66+
},
6467
{
6568
eventName: StateMachineEvent.FINALIZE,
6669
callback: handlePressOut,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ const Pressable = (props: PressableProps) => {
308308
stateMachine.handleEvent(StateMachineEvent.NATIVE_BEGIN);
309309
},
310310
onActivate: () => {
311-
if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
311+
if (Platform.OS !== 'android') {
312312
// Native.onActivate is broken with Android + hitSlop
313313
stateMachine.handleEvent(StateMachineEvent.NATIVE_START);
314314
}

0 commit comments

Comments
 (0)