Skip to content

Commit 5077539

Browse files
committed
[iOS] Fix missing onFinalize callback in Tap (#4029)
## Description On iOS, `onFinalize` callback is not triggered when `Tap` fails. Turns out that `handleGesture:` is not called from `interactionsCancelled` method. This PR fixes this problem. ## Test plan Tested on iOS 26.1 and 18.5. <details> <summary>Tested on the following example:</summary> ```tsx import { StyleSheet, View } from 'react-native'; import { GestureDetector, GestureHandlerRootView, useTapGesture, } from 'react-native-gesture-handler'; export default function App() { const tap = useTapGesture({ onFinalize: () => { console.log('[tap] onFinalize'); }, onTouchesCancel: () => { console.log('[tap] onTouchesCancel'); }, }); return ( <GestureHandlerRootView style={styles.container}> <GestureDetector gesture={tap}> <View style={styles.box} /> </GestureDetector> </GestureHandlerRootView> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, box: { width: 100, height: 100, backgroundColor: 'crimson', borderRadius: 10, }, }); ``` </details>
1 parent e7e8506 commit 5077539

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

packages/react-native-gesture-handler/apple/Handlers/RNTapHandler.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ - (void)interactionsCancelled:(NSSet *)touches withEvent:(UIEvent *)event
143143
{
144144
[_gestureHandler.pointerTracker touchesCancelled:touches withEvent:event];
145145
self.state = UIGestureRecognizerStateCancelled;
146+
147+
[self triggerAction];
146148
}
147149

148150
#if TARGET_OS_OSX

0 commit comments

Comments
 (0)