[Android] `Touchable` doesn't call onPress when you tap on a` TextInput editable={false}` child

Abierto
#4,622 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
react-native, typescript
Área
frontend, mobile

Línea de trabajo

Start by comparing RNGH Touchable and Pressable behavior with React Native's Pressable using the reproduction in the issue: a disabled TextInput inside each component on Android. Check the relevant gesture and touch handling entry points and existing tests for disabled TextInput children. Done when RNGH invokes onPress consistently with the intended Android behavior and the regression is covered by a test.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Missing info Missing repro Platform: Android
Description

Tapping a disabled TextInput doesn't trigger the onPress handler of its wrapping Touchable on Android.

The behaviour of RNGH's Touchable (and therefore Pressable) differs from the default React Native implementation. However, RN itself is inconsistent across iOS and Android, so the behaviour there also varies. Therefore, I'm not sure what is supposed to be the reference behaviour anymore, but what I can say is that it worked in RNGH v2.

Android iOS Web
RN onPress is called onPress is not called onPress is called
RNGH onPress is not called onPress is called 🤯 onPress is called

AI explanation for the default behaviour on Android:

editable={false} becomes setEnabled(false) on the native EditText.
RN's Android hit-testing treats any disabled view as box-none: "Views that are disabled should never be the target of pointer events."
So the TextInput can't be the touch target, the parent Pressable becomes the target, and onPress fires.

AI explanation for the default behaviour on iOS:

editable={false} only turns off editing. The view can still be hit.
The touch lands on the TextInput. TextInput.js attaches its own usePressability handlers whatever editable is (it just skips focus() when non-editable, around line 599).
The TextInput therefore claims the responder, and the parent Pressable never gets it, so it logs nothing.
Steps to reproduce
import { Pressable, TextInput } from 'react-native'
import { Pressable as RNGHPressable, Touchable } from 'react-native-gesture-handler'

<View>
  <Pressable onPress={() => Alert.alert('RN')}>
    <TextInput editable={false} placeholder="tap here" />
  </Pressable>

  <RNGHPressable onPress={() => Alert.alert('RNGH Pressable')}>
    <TextInput editable={false} placeholder="tap here" />
  </RNGHPressable>

  <Touchable onPress={() => Alert.alert('RNGH Touchable')}>
    <TextInput editable={false} placeholder="tap here" />
  </Touchable>
</View>
  1. Tap on the first Pressable - observe "RN" alert
  2. Tap on the secondPressable - observe no alert being shown
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.4.0

React Native version

0.86.3

Platforms

Android

JavaScript runtime

None

Workflow

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

Lenguaje dominante
TypeScript
Estrellas
6.8k
Forks
1.1k
Merge medio
1 d 23 h
PR fusionados (30 d)
46

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de software-mansion/react-native-gesture-handler

Todos los issues de software-mansion/react-native-gesture-handler

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.