[Web] A pan that starts on a Pressable presses it when the mouse button is released

Aperta
#4,713 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@mokshupadhyay ci sta già lavorando.

Dal 27/11/2026.

  • #4715 di @mokshupadhyay — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react-native, typescript

Direzione di ricerca

Start with GestureHandlerWebDelegate.onActivate and PointerEventManager.pointerDownCallback, then check how cancelsJSResponder is documented and handled on Android and iOS. The reproduction repository shows the failing behavior and expected click behavior. Done when dragging from a Pressable or SVG shape pans without pressing it, while a click without a drag still presses.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Platform: Web
Description

On Android and iOS, a gesture that activates cancels React Native's JS responder (cancelsJSResponder, true by default), so a drag that starts on a Pressable, or on a react-native-svg shape with onPress, only pans. On web the same drag pans, and then the element it started on is pressed when the mouse button is released.

I expected web to match Android and iOS: a drag that activates the pan presses nothing, while a click without a drag still presses.

As far as I can tell, on web a React Native press is the DOM's click: react-native-web's PressResponder calls onPress from onClick, and react-native-svg maps onPress to onClick. The browser fires click because the button went down and up on the same element: pointerDownCallback in PointerEventManager captures the pointer on the pressed element, and the pan carries that element along under the pointer anyway. cancelsJSResponder is accepted on web but never read: GestureHandlerWebDelegate.onActivate only sets the cursor, and nothing stops the click that ends the pointer sequence. Its documentation lists Android and iOS only.

One way to match the native platforms: when a handler with cancelsJSResponder activates, stop the click that ends that pointer sequence with a capture-phase listener on its view, as d3-drag does after a drag. A listener like that in the reproduction, set from the pan's onActivate, removes both presses, and a click without a drag still presses.

Steps to reproduce
  1. Clone the repository below, run npm install and then npx expo start --web, and open the page in Chrome.
  2. With a mouse, press the gray square (a react-native-svg Rect with onPress), drag about 100 px, and release.
  3. Do the same with the blue square (a Pressable).
  4. The line above the squares reads "Pans: 2 · Rect presses: 1 · Pressable presses: 1": each drag panned and then pressed the square it started on.
  5. For comparison, run npx expo run:android and swipe from each square: the pan count goes up and neither press count does. A tap on either square presses it on both platforms.
A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.

https://github.com/miniware9/react-native-gesture-handler-web-press-after-pan

Gesture Handler version

3.3.0 (also reproduced with 3.5.0 on web)

React Native version

0.88.1

Platforms

Web

JavaScript runtime

V8

Workflow

Using Expo Prebuild or an Expo development build

Build type

Debug mode

Device

Real device

Device model

Chrome 157 on Debian 13, with a mouse; compared with a Pixel 9a emulator on Android 17

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.