Commit 7e597d0
authored
[Android] Handle gestures on transparent views directly under the Detector (#3962)
## Description
When using the new API, the direct descendant of the Detector component
always passes through `shouldHandlerlessViewBecomeTouchTarget`. If that
view happens to be transparent, it will not be taken into account during
hit testing unless it's not a ViewGroup.
This PR adds an explicit check to ensure that views that are direct
children of a Detector component are always considered for hit testing,
even if they are transparent.
## Test plan
```jsx
import React from 'react';
import { StyleSheet, View } from 'react-native';
import {
GestureDetector,
GestureHandlerRootView,
useTapGesture,
} from 'react-native-gesture-handler';
export default function EmptyExample() {
const tap = useTapGesture({
onActivate: () => {
console.log('tap');
},
});
return (
<GestureHandlerRootView style={styles.container}>
<GestureDetector gesture={tap}>
<View style={{ flex: 1, backgroundColor: 'transparent' }} collapsable={false} />
</GestureDetector>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
```1 parent e99cf63 commit 7e597d0
File tree
1 file changed
+7
-3
lines changed- packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core
1 file changed
+7
-3
lines changedLines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
745 | 746 | | |
746 | 747 | | |
747 | 748 | | |
748 | | - | |
749 | | - | |
750 | | - | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
751 | 755 | | |
752 | 756 | | |
753 | 757 | | |
| |||
0 commit comments