`@effect/ui-native` (Effect-TS/ui): `kit/Pan` nested inside a pressable ancestor never activates on move

Aperta Adatta ai principianti
#11,094 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react-native, typescript
Ambito
mobile

Direzione di ricerca

Inizia da packages/ui-native/src/kit/Pan.ts, intorno alle righe 296–300, e segui come il target touch iniziale viene usato dagli eventi di movimento successivi. Confronta il comportamento con il test di riproduzione collegato, 08-pan-inside-pressable-never-activates-on-move/repro.test.ts. Il lavoro è completato quando il Pan annidato si attiva dopo aver superato la soglia di movimento, annulla il press dell'elemento antenato ed emette pan e panEnd con lo spostamento previsto.

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

Descrizione

partially generated with help of my ai friend - neon 4.4

Hi effect team,
I was trying out this package and wanted to report some bugs encountered while porting a library to effect native

What version of Effect is running?
  • effect: 4.1.7
  • @effect/ui & @effect/ui-native: Effect-TS/ui main at 77391ee50ae3d3175d670facbf675e9a819ba6a6
  • react-native: 0.88.1
What steps can reproduce the bug?
  1. Clone the minimal reproduction repository:
    git clone https://github.com/cliffordfajardo/effectui-native-error-reproductions.git
    cd effectui-native-error-reproductions
    pnpm install
    pnpm vitest run 08-pan-inside-pressable-never-activates-on-move
    
  2. Render a view with Pan (axis: "x", threshold: 6) inside a parent view that has a press event handler (for example, a draggable thumb inside a tap-to-seek track, or a swipe handle inside a pressable card).
  3. Dispatch topTouchStart on the child Pan node, followed by a horizontal topTouchMove (+24 px) and topTouchEnd (see 08-pan-inside-pressable-never-activates-on-move/repro.test.ts).
What is the expected behavior?

Dragging past threshold along the configured axis on the child Pan should activate Pan, cancel the ancestor press, and fire pan and panEnd (dx = 24), just as it does when the parent has no press handler.

What do you see instead?

Pan never activates and emits zero pan or panEnd events.

In packages/ui-native/src/kit/Pan.ts:296-300:

if (phase === 0) {
  const press = pressed(n)
  from = press ?? n
  ask(n, press, payload)
} else if (owner === undefined) ask(from, undefined, payload)

On phase === 0 (topTouchStart), pressed(n) returns the ancestor pressable node press, so from is set to press rather than the actual touch target n. Because threshold > 0 (or axis is constrained), ready() is false at (dx = 0, dy = 0), so owner remains undefined. On subsequent phase === 1 (topTouchMove) events, ask(from, undefined, payload) walks upward starting from press (press -> press.parent -> ...) and never visits the descendant n again.

Additional information

Keeping from = n (the actual touch target) on phase === 0 so subsequent ask(from, ...) walks start from the child Pan node — while still passing press (or resolving pressed(n) when claiming) to cancel the ancestor pressable — allows nested Pan recognizers inside pressable ancestors to activate properly.

Lingua principale
TypeScript
Stelle
16.7k
Fork
808
Merge medio
21h 22m
PR unite (30g)
486

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 Effect-TS/effect

Tutte le issue di Effect-TS/effect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.