Commit 3b7a19e
authored
## Description
### Problem
Currently the following configuration:
```jsx
<GestureDetector ... >
<Text> ... </Text>
</GestureDetector>
```
does not work on `iOS`. This is due to change `react-native` introduced in 0.79 - `hitTest` in `RCTParagraphTextView` now returns `nil` by default ([see here](https://github.com/facebook/react-native/blob/dcbbf275cbc4150820691a4fbc254b198cc92bdd/packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm#L379)). This results in native `UIGestureRecognizer` not responding to touches.
### Solution
We no longer attach native recognizer to `RCTParagraphTextView`, but to its parent - `RCTParagraphComponentView`. The problem with this approach is that `handleGesture` method uses `reactTag` property, which on `RCTParagraphComponentView` is `nil`. This is why we use `reactTag` from `RCTParagraphTextView` when sending event to `JS` side.
Fixes #3581
## Test plan
<details>
<summary>Tested on the following code:</summary>
```jsx
import React from 'react';
import { StyleSheet, Text } from 'react-native';
import {
Gesture,
GestureDetector,
GestureHandlerRootView,
} from 'react-native-gesture-handler';
export default function EmptyExample() {
const g = Gesture.Tap().onEnd(() => {
console.log('Tapped!');
});
return (
<GestureHandlerRootView style={styles.container}>
<GestureDetector gesture={g}>
<Text>
Click me
<Text> Me too! </Text>
</Text>
</GestureDetector>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
```
</details>
1 parent a80e93d commit 3b7a19e
2 files changed
Lines changed: 45 additions & 6 deletions
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
| |||
Lines changed: 41 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
218 | 226 | | |
219 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
220 | 239 | | |
221 | | - | |
| 240 | + | |
222 | 241 | | |
223 | | - | |
224 | | - | |
225 | 242 | | |
226 | | - | |
| 243 | + | |
| 244 | + | |
227 | 245 | | |
228 | 246 | | |
229 | 247 | | |
| |||
249 | 267 | | |
250 | 268 | | |
251 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
252 | 283 | | |
253 | 284 | | |
| 285 | + | |
| 286 | + | |
254 | 287 | | |
255 | 288 | | |
256 | 289 | | |
257 | | - | |
| 290 | + | |
258 | 291 | | |
259 | 292 | | |
260 | 293 | | |
| |||
266 | 299 | | |
267 | 300 | | |
268 | 301 | | |
269 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
270 | 305 | | |
271 | 306 | | |
272 | 307 | | |
| |||
0 commit comments