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

未关闭 适合新手
#11,094 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
react-native, typescript
领域
mobile

调研方向

从 packages/ui-native/src/kit/Pan.ts 第 296–300 行附近开始,追踪后续移动事件如何使用初始触摸目标。将其行为与链接的复现测试 08-pan-inside-pressable-never-activates-on-move/repro.test.ts 进行比较。当嵌套的 Pan 在移动超过阈值后激活、取消祖先的 press,并以预期的位移发出 pan 和 panEnd 时,即为完成。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
16.7k
派生
808
平均合并
21 小时 22 分钟
30 天内合并 PR
486

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Effect-TS/effect 的其他 Issue

查看 Effect-TS/effect 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。