Skip to content

Commit ba999e0

Browse files
authored
[Android] Fix hitSlop on native detector (#4049)
## Description `hitSlop` can be used to shrink area of the interactive part of component. On Android, it can also be used to expand it. This is currently broken with Native Detector, as it doesn't consider `hitSlop` itself. Making `recordViewHandlersForPointer` run unconditionally for native detector resolves this issue. > [!NOTE] > There are additional checks inside `recordViewHandlersForPointer`, so it should be safe. ## Test plan <details> <summary>Tested on the following example:</summary> ```tsx import { View, StyleSheet } from 'react-native'; import { Gesture, GestureDetector, GestureHandlerRootView, usePanGesture, } from 'react-native-gesture-handler'; export default function App() { const pan = usePanGesture({ onUpdate: (e) => { console.log('[V3]', e); }, hitSlop: 25, }); const oldPan = Gesture.Pan() .onUpdate((e) => { console.log('[V2]', e); }) .hitSlop(25); return ( <GestureHandlerRootView style={styles.container}> <GestureDetector gesture={pan}> <View style={styles.box} /> </GestureDetector> <GestureDetector gesture={oldPan}> <View style={styles.box} /> </GestureDetector> </GestureHandlerRootView> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 50, }, box: { height: 150, width: 150, backgroundColor: 'blue', borderRadius: 20, }, }); ``` </details>
1 parent 2e98457 commit ba999e0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ class GestureHandlerOrchestrator(
659659
is ViewGroup -> {
660660
extractGestureHandlers(view, coords, pointerId, event).also { found ->
661661
// A child view is handling touch, also extract handlers attached to this view
662-
if (found) {
662+
if (found || view is RNGestureHandlerDetectorView) {
663663
recordViewHandlersForPointer(view, coords, pointerId, event)
664664
}
665665
}

0 commit comments

Comments
 (0)