Files
heroui-vue/docs/migrations/B01-review-2.md
T
maoyingjie e797c25d46 fix: real trigger owns long press, Vue click chain and layered Esc
- DropdownTrigger takes over the longPress press lifecycle in capture phase and
  cancels Reka's own open/toggle through its defaultPrevented guard; DropdownRoot
  no longer wraps the whole menu content. Short click, Enter and Space now open
  exactly once, and release cannot close the menu again.
- MenuItem hands user handlers plus activation to Vue as one DOM onClick array,
  so preventDefault, capture and stopImmediatePropagation keep native semantics
  instead of a hand-rolled handler loop.
- DropdownSubmenuTrigger owns its own open state and closes only its level on
  Escape, restoring focus to the submenu trigger; the parent menu stays open and
  a second Escape closes the root.
2026-10-24 21:42:25 +08:00

40 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# B01 第二次复核
2026-10-24;feat/b01-menu-dropdown / 1692c6b。暂不通过,不合main。无需SSR/水合/Nuxt。
## 已通过的修复
上一轮4项探针全部通过:选择项角色/checked状态、普通preventDefault取消、避免嵌套menuitem、独立Menu不再抛缺少上下文错误。原B01测试现8项通过;两文件共12项通过,类型检查通过。这些无需回退或整批重写。
## 仍需修复
### 1. [P1] longPress短点击仍直接打开菜单
DropdownRoot把长按click拦截放在触发按钮外的包裹层。实际DropdownTrigger的Reka click处理器先执行并把open设true,然后事件才冒泡到Root包裹层;此时preventDefault/stopImmediatePropagation无法撤销已发生的打开。
新回归点击真实 `DropdownTrigger > Button`,未发生长按即显示MenuItem。现有长按测试只在包裹层派发事件,绕过真实触发器默认行为,因而漏检。
修复应由真实触发器参与统一触发模式,不靠晚到的冒泡拦截。覆盖短按不开、达到阈值打开、长按后release/click不反向关闭、移动取消、pointercancel、非主键/非主指针、卸载清理。避免Root包裹整个菜单内容后把条目激活也当作长按触发。
### 2. [P1] longPress的Enter激活被执行两次
同样由于监听位置,Enter先由Reka DropdownTrigger打开,然后冒泡到包裹层再次 `setOpen(!isOpen)`,立即关闭,键盘备用激活失效。新回归向真实button发送Enter后菜单仍关闭。Space也需要验证,不能只修短点击。
### 3. [P1] 手动遍历click数组破坏stopImmediatePropagation
MenuItem的invokeClick使用for逐个调用用户数组处理器。第一个处理器stopImmediatePropagation后,第二个仍执行;激活链也没有可靠终止。此类问题已在之前迁移规范中明确禁止。
新回归使用onClick=[event=>event.stopImmediatePropagation(), second],second仍调用一次。改用Vue实际DOM处理器合并语义与明确取消边界,不读取/伪造Vue私有_stopped,也不手工循环模拟invoker。保留普通preventDefault、capture和键盘取消,以及单次动作/选择/关闭回归。
### 4. [P1] Esc逐层关闭仍未实现
B01-menu-dropdown报告末尾仍明确写“Esc在子菜单内仍会一次关闭整栈…待后续”。这是本批原契约,不能以Reka组合差异为理由移到未授权的后续共享弹层任务。完成本家族最内层Esc关闭/父层保留/焦点回子触发器,再Esc关闭根层。不要改共享overlay内核或拦所有文档级Esc掩盖问题。
## 测试证据
`tests/b01-review.probe.test.ts`现7项:原4项通过,新增上述前3项失败。原 `tests/b01-menu-dropdown.test.ts` 8项通过。Esc本轮依据实现者报告确认仍未完成,未冒充本轮浏览器验证结果。
## 交付要求
继续当前分支修复以上4项;优先让真实DropdownTrigger拥有触发事件与模式,再正确处理子菜单生命周期。保留已经修对的选择ARIA/指示器/类型/文档。新增长按测试必须操作真实按钮,不能只操作Root包裹层;子菜单Esc必须真实焦点在最内层时操作。重跑相关/全量回归、类型、文档构建、独立浏览器产物消费,浏览器只重点验上述交互。不创建下一组件批次,不自行合main。