Commit ef686fc
authored
## Description
#3127 introduced our own implementation of `findNodeHandle` on web. Unfortunately, it doesn't work if someone uses `GestureDetector` on SVG elements, e.g.:
```jsx
<Svg width={200} height={200}>
<GestureDetector gesture={tapGestureCircle}>
<Circle r={200} cx={210} cy={210} fill={circleFill} />
</GestureDetector>
</Svg>
```
Code above would render additional `div` element with `display: 'contents';`, which would break `SVG`.
This PR does the following things:
1. Bumps `react-native-svg` version
2. Modifies `Wrap` component such that now if element is part of `SVG` it doesn't wrap it into additional `div`
3. Adjusts `findNodeHandle` function to properly handle `SVG` refs
## Test plan
<details>
<summary>Tested on the following example:</summary>
```jsx
import {
GestureHandlerRootView,
GestureDetector,
Gesture,
} from 'react-native-gesture-handler';
import { View } from 'react-native';
import { Svg, Circle } from 'react-native-svg';
import { useState, useCallback } from 'react';
export default function App() {
const [circleFill, setCircleFill] = useState('blue');
const switchCircleColor = useCallback(
() => setCircleFill((old) => (old === 'blue' ? 'brown' : 'blue')),
[setCircleFill]
);
const tapGestureCircle = Gesture.Tap().runOnJS(true).onEnd(switchCircleColor);
return (
<GestureHandlerRootView style={{ flex: 1, paddingTop: 200 }}>
<View style={{ padding: 10, borderWidth: 1, alignSelf: 'flex-start' }}>
<Svg width={200} height={200}>
<GestureDetector gesture={tapGestureCircle}>
<Circle r={200} cx={210} cy={210} fill={circleFill} />
</GestureDetector>
</Svg>
</View>
</GestureHandlerRootView>
);
}
```
</details>
1 parent da9eed8 commit ef686fc
File tree
6 files changed
+86
-23
lines changed- example
- src
- handlers/gestures/GestureDetector
- web
6 files changed
+86
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7165 | 7165 | | |
7166 | 7166 | | |
7167 | 7167 | | |
7168 | | - | |
7169 | | - | |
7170 | | - | |
7171 | | - | |
7172 | | - | |
7173 | | - | |
| 7168 | + | |
| 7169 | + | |
7174 | 7170 | | |
7175 | 7171 | | |
7176 | 7172 | | |
| |||
7199 | 7195 | | |
7200 | 7196 | | |
7201 | 7197 | | |
7202 | | - | |
7203 | | - | |
7204 | | - | |
7205 | | - | |
| 7198 | + | |
| 7199 | + | |
| 7200 | + | |
| 7201 | + | |
7206 | 7202 | | |
7207 | 7203 | | |
7208 | 7204 | | |
| 7205 | + | |
7209 | 7206 | | |
7210 | 7207 | | |
7211 | 7208 | | |
| |||
8580 | 8577 | | |
8581 | 8578 | | |
8582 | 8579 | | |
8583 | | - | |
| 8580 | + | |
8584 | 8581 | | |
8585 | 8582 | | |
8586 | 8583 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| 2 | + | |
5 | 3 | | |
6 | 4 | | |
7 | | - | |
8 | | - | |
| 5 | + | |
| 6 | + | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
16 | | - | |
| 14 | + | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | | - | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
15 | 22 | | |
16 | 23 | | |
17 | | - | |
| 24 | + | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
21 | 28 | | |
22 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
23 | 32 | | |
24 | 33 | | |
25 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
3 | 8 | | |
4 | 9 | | |
5 | 10 | | |
| |||
227 | 232 | | |
228 | 233 | | |
229 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
0 commit comments