[iOS] Touchable ignores taps on nested Text after selectable was toggled
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- objective-c, react-native
Direzione di ricerca
Start in the iOS implementation of -[RNGestureHandlerButton hitTest:withEvent:] and shouldHandleTouch:atPoint:, then inspect how findGestureHandlerByRecognizer handles enabled recognizers that do not belong to RNGH. Reproduce with the provided React Native example by toggling selectable off after enabling it; done means taps on the nested text trigger the same press events as taps elsewhere in the Touchable.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
On iOS, a Touchable with a <Text> child stops responding to taps that land on the text after that <Text> has had selectable turned on and off again. There's no press feedback, and none of onPressIn / onPress / onPressOut fire. Taps on the rest of the Touchable, outside the text, still work. Expected: every tap inside the Touchable presses it, including taps on its children.
Cause. -[RNGestureHandlerButton hitTest:withEvent:] walks up from the deepest view under the touch and stops at the first view for which shouldHandleTouch:atPoint: returns YES. In shouldHandleTouch:atPoint:, any enabled gesture recognizer that doesn't belong to RNGH (findGestureHandlerByRecognizer returns nil) sets gestureRecognizerWantsEvent = YES. So a child view with even a passive recognizer, one that only observes touches, becomes the hit view, and the button never starts tracking the touch.
Where the passive recognizer comes from. When a <Text> becomes selectable, React Native adds a UIEditMenuInteraction and a long-press recognizer to its RCTParagraphComponentView, and UIKit additionally attaches a private click-feedback generator to the view. When selectable goes back to false, React Native removes the edit-menu interaction and the long-press recognizer, but UIKit's feedback generator and its recognizer stay. This is the label's native view at that point (lldb):
RNGestureHandlerButton
RCTParagraphComponentView
GR <_UIFeedbackGeneratorGestureRecognizer; state = Possible; cancelsTouchesInView = NO; ...> enabled=1
INTERACTION <_UIClickPresentationFeedbackGenerator>
RCTParagraphTextView
_UIFeedbackGeneratorGestureRecognizer has cancelsTouchesInView = NO, but because it isn't an RNGH recognizer, shouldHandleTouch:atPoint: treats the text view as handling touches.
In a real app this rarely looks tied to selectable. Fabric recycles RCTParagraphComponentViews, so a view that was ever selectable anywhere in the app can later be reused for a <Text> inside a Touchable that was never selectable. The Touchable then randomly ignores taps on its text, and only taps that happen to land on the text are lost.
This is the same class of problem as #3376. The isEnabled == YES filter added for it in shouldHandleTouch:atPoint: skips disabled system recognizers, but not enabled passive ones.
What we verified on the affected device:
- No RNGH gesture events are dispatched for the lost taps, so no RNGH handler claims the touch.
- Making the text non-hittable (
pointerEvents="none"on a wrapper around the<Text>) restores every tap. - In the view hierarchy, the passive recognizer above is present on the text view of every affected
Touchableand absent from the ones that work.
Steps to reproduce
import { useState } from 'react';
import { StyleSheet, Switch, Text, View } from 'react-native';
import { GestureHandlerRootView, Touchable } from 'react-native-gesture-handler';
export default function App() {
const [selectable, setSelectable] = useState(false);
const [presses, setPresses] = useState(0);
return (
<GestureHandlerRootView style={styles.container}>
<View style={styles.row}>
<Text>selectable</Text>
<Switch value={selectable} onValueChange={setSelectable} />
</View>
<Touchable style={styles.button} onPress={() => setPresses((count) => count + 1)}>
<Text selectable={selectable}>Label</Text>
</Touchable>
<Text>Presses: {presses}</Text>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', alignItems: 'center', gap: 16 },
row: { flexDirection: 'row', alignItems: 'center', gap: 8 },
button: { paddingHorizontal: 48, paddingVertical: 20, borderRadius: 12, backgroundColor: '#d0d8e8' },
});
- Tap the word "Label": the counter increases.
- Turn
selectableon, then off again. No long-press is needed. - Tap the word "Label" again: no press feedback, and the counter doesn't change.
- Tap the
Touchableoutside the text: it still presses normally.
View recycling reproduces it too: render a <Text selectable> elsewhere, then unmount it in the same commit that mounts a Touchable with a plain <Text> child. The new <Text> can reuse the old paragraph view, and taps on it are lost the same way.
A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.
Gesture Handler version
3.5.0
React Native version
0.86.3
Platforms
iOS
JavaScript runtime
None
Workflow
None
Build type
Debug mode
Device
Real device
Device model
iPad Air 11-inch (M3) (iPadOS 26.6.1)
Acknowledgements
Yes
- Lingua principale
- TypeScript
- Stelle
- 6.8k
- Fork
- 1.1k
- Merge medio
- 2g 17h
- PR unite (30g)
- 28
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di software-mansion/react-native-gesture-handler
-
GestureDetector should bubble touches if all gestures fail (or some other generalized solution)ApertaMissing repro Platform: Android Platform: iOS
Difficoltà 5/5 Più di una settimana Idoneità per principianti 39/100
software-mansion/react-native-gesture-handler#4714 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
[Web] A pan that starts on a Pressable presses it when the mouse button is releasedForse già presa @mokshupadhyay l’ha presa 2 giorni fa. ApertaPlatform: Web
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
software-mansion/react-native-gesture-handler#4713 ·
I maintainer di solito rispondono entro 2 giorni
-
[iOS] Crash at app exit: static `_managers` map destroyed while `flushOperations` reads itForse già presa @beqramo l’ha presa 5 giorni fa. ApertaMissing info Missing repro Platform: iOS Platform: MacOS
Difficoltà 2/5 1-3 ore Idoneità per principianti 30/100
software-mansion/react-native-gesture-handler#4711 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
[iOS][Fabric] Recognizer of a live handler stays on a recycled view and takes every drag on the component that reuses itForse già presa @nihar777 l’ha presa 6 giorni fa. ApertaPlatform: iOS
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
software-mansion/react-native-gesture-handler#4710 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
[iOS] Button press feedback invisible on quick taps when Reduce Motion is enabledForse già presa @andreialecu l’ha presa 7 giorni fa. ApertaMissing info Platform: iOS Platform: MacOS
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
software-mansion/react-native-gesture-handler#4707 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di software-mansion/react-native-gesture-handler
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
check:failed streams:edit
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
iptv-org/iptv#60585 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Critical path skips a child span that ends exactly when the next one startsForse già presa @Piyush4801 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
jaegertracing/jaeger-ui#4865 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
anthropics/claude-code#112972 ·