GestureDetector should bubble touches if all gestures fail (or some other generalized solution)

Abierto
#4,714 1 comentario 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
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
39/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
react-native, typescript
Área
mobile

Línea de trabajo

Start by reading the GestureDetector and gesture coordination documentation or entry points mentioned by the project; the issue names no specific files or tests. Explore how nested gestures handle touches when recognizers fail, then define what a generalized bubbling or coordination solution should do. Done means the project has a clear approach for the described nested SelectableText and Bubble case, with behavior that can be verified across Android and iOS.

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

Descripción

Missing repro Platform: Android Platform: iOS
Description

Imagine the following example component hierarchy:

Bubble( Message( MarkdownMessage( MarkdownView( SelectableText, SelectableText, ... ) ) ) )

Where SelectableText contains a GestureDetector and has a tap + longPress + pan + ... gestures to make text selectable.

What happens if you want to make the Bubble tappable?

Right now this is borderline impossible because:

  • If you put a Pressable inside Bubble, it would never get triggered because SelectableText deep down has GestureDetectors that are eating up all touches, even if the gestures are all failing
  • If you put a GestureDetector inside Bubble and then attach a tapGesture to it, then the same problem as above happens, except that if you SOMEHOW manage to deliver the tapGesture to every SelectableText deep down downstream, then requireToFail/block/simultaneousWith can be used to define coordination logic

Except there is no clean way to do the latter at all? Like even if I decided to do massive props drilling (somehow), what would SelectableText's props be? gesturesToRequireToFail and gesturesToBlock and gesturesTo... what? SelectableText is a general component

I think at least for this example automatic touch propagation if all registered gestures fail works, but perhaps there needs to be a more generalized/flexible solution to this problem.

Right now an innermost GestureDetector anywhere in the tree effectively takes exclusive access to touches made on the pixels it covers, simply because there's no practical way to bubble touches properly

(I can try rephrase this issue if it isn't clear enough)

Steps to reproduce

A hierarchy like this (where every component lives in a different file):

<!-- ⚠️ There's no practical way to coordinate between `bubbleTapGesture` and `bunchOfGestures`s downstream -->
<Bubble>
	<GestureDetector gestures={bubbleTapGesture}>
		<Message>
			<MarkdownMessage>
				<MarkdownView>
					<SelectableText>
						<GestureDetector gestures={bunchOfGestures}>
							<!-- Content -->
						</GestureDetector>
					</SelectableText>
					<SelectableText>
						<GestureDetector gestures={bunchOfGestures}>
							<!-- Content -->
						</GestureDetector>
					</SelectableText>
					<SelectableText>
						<GestureDetector gestures={bunchOfGestures}>
							<!-- Content -->
						</GestureDetector>
					</SelectableText>
					<SelectableText>
						<GestureDetector gestures={bunchOfGestures}>
							<!-- Content -->
						</GestureDetector>
					</SelectableText>
					<SelectableText>
						<GestureDetector gestures={bunchOfGestures}>
							<!-- Content -->
						</GestureDetector>
					</SelectableText>
				</MarkdownView>
			</MarkdownMessage>
		</Message>
	</GestureDetector>
</Bubble>
A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.

It's not a "bug" it's a usage/architectural problem

Gesture Handler version

3.4.0

React Native version

0.88.0

Platforms

Android, iOS

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
2 d 17 h
PR fusionados (30 d)
28

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.