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

Đang mở Phù hợp với người mới
#11,094 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react-native, typescript
Lĩnh vực
mobile

Hướng nghiên cứu

Bắt đầu với packages/ui-native/src/kit/Pan.ts quanh các dòng 296–300 và theo dõi cách mục tiêu chạm ban đầu được dùng trong các sự kiện di chuyển tiếp theo. So sánh hành vi với bài kiểm tra tái hiện được liên kết, 08-pan-inside-pressable-never-activates-on-move/repro.test.ts. Hoàn thành khi Pan lồng nhau được kích hoạt sau khi di chuyển vượt ngưỡng, hủy press của phần tử tổ tiên và phát pan cùng panEnd với độ dịch chuyển như mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
16.7k
Fork
808
Merge trung bình
21 giờ 22 phút
Pull request đã merge (30 ngày)
486

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Effect-TS/effect

Tất cả issue của Effect-TS/effect

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.