[iOS] Touchable ignores taps on nested Text after selectable was toggled

Aperta
#4,700 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@shahjahanpak ci sta già lavorando.

Dal 22/11/2026.

  • #4709 di @shahjahanpak — aperta

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
Ambito
mobile, testing

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

Missing info Platform: iOS
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 Touchable and 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' },
});
  1. Tap the word "Label": the counter increases.
  2. Turn selectable on, then off again. No long-press is needed.
  3. Tap the word "Label" again: no press feedback, and the counter doesn't change.
  4. Tap the Touchable outside 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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di software-mansion/react-native-gesture-handler

Tutte le issue di software-mansion/react-native-gesture-handler

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.