Commit 4285b4f
[web] handle common props in virtual detector (#3982)
## Description
Common web-only props `enableContextMenu`, `touchAction`, `userSelect`
were not properly handled inside virtual detector. This PR fixes it.
## Test plan
Tested on the following example
<details>
```tsx
import { COLORS, commonStyles, Feedback } from '../common-app/src/common';
import React, { useRef } from 'react';
import { View } from 'react-native';
import {
InterceptingGestureDetector,
useTapGesture,
VirtualGestureDetector,
} from 'react-native-gesture-handler';
import Svg, { Circle, Rect } from 'react-native-svg';
export default function LogicDetectorExample() {
const feedbackRef = useRef<{ showMessage: (msg: string) => void }>(null);
const circleElementTap = useTapGesture({
onActivate: () => {
feedbackRef.current?.showMessage('Tapped circle!');
},
disableReanimated: true,
});
const rectElementTap = useTapGesture({
onActivate: () => {
feedbackRef.current?.showMessage('Tapped parallelogram!');
},
disableReanimated: true,
});
const containerTap = useTapGesture({
onActivate: () => {
feedbackRef.current?.showMessage('Tapped container!');
},
disableReanimated: true,
});
// onPress must be set to enable gesture recognition on svg
// eslint-disable-next-line @typescript-eslint/no-empty-function
const noop = () => { };
return (
<View style={commonStyles.centerView}>
<InterceptingGestureDetector gesture={containerTap}>
<Svg
height="250"
width="250"
style={{ backgroundColor: COLORS.PURPLE }}>
<VirtualGestureDetector gesture={circleElementTap}>
<Circle
cx="125"
cy="125"
r="125"
fill={COLORS.NAVY}
onPress={noop}
/>
</VirtualGestureDetector>
<VirtualGestureDetector enableContextMenu={true} gesture={rectElementTap}>
<Rect
skewX="45"
width="125"
height="250"
fill={COLORS.KINDA_BLUE}
onPress={noop}
/>
</VirtualGestureDetector>
</Svg>
</InterceptingGestureDetector>
<Feedback ref={feedbackRef} />
</View>
);
}
```
</details>
---------
Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>1 parent b8c72e2 commit 4285b4f
5 files changed
Lines changed: 54 additions & 15 deletions
File tree
- packages/react-native-gesture-handler/src/v3
- detectors
- VirtualDetector
- types
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
174 | 177 | | |
175 | 178 | | |
176 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
177 | 188 | | |
178 | 189 | | |
179 | 190 | | |
| |||
Lines changed: 24 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | | - | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
30 | 37 | | |
31 | 38 | | |
32 | 39 | | |
| |||
41 | 48 | | |
42 | 49 | | |
43 | 50 | | |
44 | | - | |
| 51 | + | |
45 | 52 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
51 | 66 | | |
52 | 67 | | |
53 | 68 | | |
| |||
261 | 276 | | |
262 | 277 | | |
263 | 278 | | |
264 | | - | |
| 279 | + | |
265 | 280 | | |
266 | 281 | | |
267 | 282 | | |
| |||
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
79 | 82 | | |
80 | | - | |
81 | 83 | | |
82 | | - | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
87 | 97 | | |
88 | 98 | | |
89 | 99 | | |
| |||
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 31 | + | |
| 32 | + | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
0 commit comments