Commit 4768080
[ios] fix pressable with intercepting detector (#4041)
## Description
On iOS, when under pressable, we had an intercepting detector handling a
nested text gesture, pressable did not activate when we pressed on the
part of the text with no virtual gesture attached to it. This PR should
fix the issue.
The problem was that when the button was hit-testing its children, it
assumed that the gesture recognizer always wanted to receive events (it
was only checking whether there was any). The new implementation goes
through the list of found recognizers, checking if they want to handle
touch at the specified point.
Note: on web the nested text gesture never activates when under a
pressable, web needs further care.
## Test plan
Tested on the following example
<details>
```tsx
import { Text } from 'react-native';
import {
GestureHandlerRootView,
InterceptingGestureDetector,
Pressable,
VirtualGestureDetector,
useTapGesture,
} from 'react-native-gesture-handler';
export default function Reproduction() {
const innerTap = useTapGesture({
onActivate: () => {
'worklet';
console.log('RNGH: Inner onPress');
},
});
return (
<GestureHandlerRootView
style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Pressable
style={{ width: 100, height: 100, backgroundColor: 'pink' }}
onPress={() => console.log('RNGH: Pressable onPress')}>
<InterceptingGestureDetector>
<Text>
Outer{' '}
<VirtualGestureDetector gesture={innerTap}>
<Text>Inner</Text>
</VirtualGestureDetector>
</Text>
</InterceptingGestureDetector>
</Pressable>
</GestureHandlerRootView>
);
}
```
---------
Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>1 parent d4f7818 commit 4768080
3 files changed
Lines changed: 68 additions & 26 deletions
File tree
- packages/react-native-gesture-handler/apple
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
744 | 744 | | |
745 | 745 | | |
746 | 746 | | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
747 | 774 | | |
748 | 775 | | |
749 | 776 | | |
| |||
Lines changed: 40 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | 169 | | |
194 | 170 | | |
195 | 171 | | |
| |||
667 | 643 | | |
668 | 644 | | |
669 | 645 | | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
670 | 684 | | |
671 | 685 | | |
672 | 686 | | |
| |||
680 | 694 | | |
681 | 695 | | |
682 | 696 | | |
683 | | - | |
| 697 | + | |
684 | 698 | | |
685 | 699 | | |
686 | 700 | | |
| |||
693 | 707 | | |
694 | 708 | | |
695 | 709 | | |
696 | | - | |
| 710 | + | |
697 | 711 | | |
698 | 712 | | |
699 | 713 | | |
| |||
0 commit comments