From 9eb7d2f102b877507d8b04d4ec16939a170473e6 Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Wed, 19 Nov 2025 10:26:20 +0100 Subject: [PATCH] Don't handle events on the detector surface --- .../react/RNGestureHandlerDetectorViewManager.kt | 5 +++++ .../src/specs/RNGestureHandlerDetectorNativeComponent.ts | 8 ++++++++ .../src/v3/detectors/NativeDetector.tsx | 1 + .../VirtualDetector/InterceptingGestureDetector.tsx | 1 + 4 files changed, 15 insertions(+) diff --git a/packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorViewManager.kt b/packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorViewManager.kt index df898219d8..4ed03c7487 100644 --- a/packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorViewManager.kt +++ b/packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorViewManager.kt @@ -2,6 +2,7 @@ package com.swmansion.gesturehandler.react import com.facebook.react.bridge.ReadableArray import com.facebook.react.module.annotations.ReactModule +import com.facebook.react.uimanager.PointerEvents.Companion.parsePointerEvents import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.ViewGroupManager import com.facebook.react.uimanager.ViewManagerDelegate @@ -45,4 +46,8 @@ class RNGestureHandlerDetectorViewManager : view.onViewDrop() super.onDropViewInstance(view) } + + override fun setPointerEvents(view: RNGestureHandlerDetectorView, pointerEventsStr: String?) { + view.pointerEvents = parsePointerEvents(pointerEventsStr) + } } diff --git a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts index c14f734d80..29c4a1ed96 100644 --- a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts +++ b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts @@ -4,6 +4,7 @@ import type { DirectEventHandler, UnsafeMixed, Double, + WithDefault, } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from 'react-native'; @@ -47,6 +48,8 @@ export interface VirtualChildrenProps { viewTag: Int32; } +// @ts-expect-error WithDefault adds `| null` to the type, which doesn't align with ViewProps.pointerEvents +// Using Exclude to remove null from the type makes the error go away, but breaks codegen. export interface NativeProps extends ViewProps { onGestureHandlerEvent?: DirectEventHandler; onGestureHandlerStateChange?: DirectEventHandler; @@ -59,6 +62,11 @@ export interface NativeProps extends ViewProps { handlerTags: Int32[]; moduleId: Int32; virtualChildren: VirtualChildrenProps[]; + + pointerEvents?: WithDefault< + 'box-none' | 'none' | 'box-only' | 'auto', + 'auto' + >; } export default codegenNativeComponent('RNGestureHandlerDetector', { diff --git a/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx b/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx index 69360e40b0..c9ceb7463b 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx @@ -28,6 +28,7 @@ export function NativeDetector({ return ( ({ return ( createGestureEventHandler('onGestureHandlerStateChange'),