Skip to content

Commit 0f13426

Browse files
Fix intercepting detector props (#3952)
## Description `InterceptingDetectorProps` was missing some types from `GestureDetectorProps` this PR makes both types extend `CommonGestureDetectorProps` ## Test plan `yarn ts-check` --------- Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>
1 parent 599b47c commit 0f13426

File tree

5 files changed

+35
-12
lines changed

5 files changed

+35
-12
lines changed

.github/workflows/rngh-api-v3.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
runs-on: ubuntu-latest
1919
concurrency:
20-
group: jest-${{ github.ref }}
20+
group: rngh-api-v3-${{ github.ref }}
2121
cancel-in-progress: true
2222

2323
steps:

packages/react-native-gesture-handler/jestSetup.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
21
jest.mock('./src/RNGestureHandlerModule', () => require('./src/mocks/module'));
3-
jest.mock('./src/components/GestureButtons', () => require('./src/mocks/gestureButtons'));
4-
jest.mock('./src/components/Pressable/Pressable', () => require('./src/mocks/Pressable'));
5-
jest.mock('./src/components/GestureComponents', () => require('./src/mocks/gestureComponents'));
6-
jest.mock('./src/v3/detectors/HostGestureDetector', () => require('./src/mocks/hostDetector'));
2+
jest.mock('./src/components/GestureButtons', () =>
3+
require('./src/mocks/GestureButtons')
4+
);
5+
jest.mock('./src/components/Pressable/Pressable', () =>
6+
require('./src/mocks/Pressable')
7+
);
8+
jest.mock('./src/components/GestureComponents', () =>
9+
require('./src/mocks/gestureComponents')
10+
);
11+
jest.mock('./src/v3/detectors/HostGestureDetector', () =>
12+
require('./src/mocks/hostDetector')
13+
);
714

815
jest.mock('./lib/commonjs/RNGestureHandlerModule', () =>
916
require('./lib/commonjs/mocks/module')

packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ interface VirtualChildrenForNative {
3232
export function InterceptingGestureDetector<THandlerData, TConfig>({
3333
gesture,
3434
children,
35+
touchAction,
36+
userSelect,
37+
enableContextMenu,
3538
}: InterceptingGestureDetectorProps<THandlerData, TConfig>) {
3639
useEnsureGestureHandlerRootView();
3740

@@ -224,6 +227,9 @@ export function InterceptingGestureDetector<THandlerData, TConfig>({
224227
return (
225228
<InterceptingDetectorContext value={contextValue}>
226229
<NativeDetectorComponent
230+
touchAction={touchAction}
231+
userSelect={userSelect}
232+
enableContextMenu={enableContextMenu}
227233
pointerEvents={'box-none'}
228234
// @ts-ignore This is a type mismatch between RNGH types and RN Codegen types
229235
onGestureHandlerStateChange={jsEventHandler}

packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/VirtualDetector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
useInterceptingDetectorContext,
77
} from './useInterceptingDetectorContext';
88
import { isComposedGesture } from '../../hooks/utils/relationUtils';
9-
import { NativeDetectorProps } from '../common';
9+
import { VirtualDetectorProps } from '../common';
1010
import { configureRelations } from '../utils';
1111
import { tagMessage } from '../../../utils';
1212
import { DetectorCallbacks, VirtualChild } from '../../types';
@@ -24,7 +24,7 @@ function useRequiredInterceptingDetectorContext() {
2424
}
2525

2626
export function VirtualDetector<THandlerData, TConfig>(
27-
props: NativeDetectorProps<THandlerData, TConfig>
27+
props: VirtualDetectorProps<THandlerData, TConfig>
2828
) {
2929
// Don't memoize virtual detectors to be able to listen to changes in children
3030
// TODO: replace with MutationObserver when it rolls out in React Native

packages/react-native-gesture-handler/src/v3/detectors/common.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,29 @@ export enum GestureDetectorType {
1111
Intercepting,
1212
}
1313

14-
export interface NativeDetectorProps<THandlerData, TConfig> {
14+
interface CommonGestureDetectorProps {
1515
children?: React.ReactNode;
16-
gesture: Gesture<THandlerData, TConfig>;
1716
userSelect?: UserSelect;
1817
touchAction?: TouchAction;
1918
enableContextMenu?: boolean;
2019
}
2120

22-
export interface InterceptingGestureDetectorProps<THandlerData, TConfig> {
23-
children?: React.ReactNode;
21+
export interface NativeDetectorProps<THandlerData, TConfig>
22+
extends CommonGestureDetectorProps {
23+
gesture: Gesture<THandlerData, TConfig>;
24+
}
25+
26+
export interface InterceptingGestureDetectorProps<THandlerData, TConfig>
27+
extends CommonGestureDetectorProps {
2428
gesture?: Gesture<THandlerData, TConfig>;
2529
}
2630

31+
// TODO: Handle CommonGestureDetectorProps inside VirtualGestureDetector
32+
export interface VirtualDetectorProps<THandlerData, TConfig> {
33+
children?: React.ReactNode;
34+
gesture: Gesture<THandlerData, TConfig>;
35+
}
36+
2737
export type GestureDetectorProps<THandlerData, TConfig> =
2838
| NativeDetectorProps<THandlerData, TConfig>
2939
| InterceptingGestureDetectorProps<THandlerData, TConfig>

0 commit comments

Comments
 (0)