fix: resolve close policy, handler merging and submenu panel props

- Menu forwards the raw close policy and the item resolves item > menu
  (boolean or function) > per-mode default, so action items close by default and
  an explicit single/multiple policy is no longer pre-empted.
- Root popover chains caller handlers with the internal ones for keydown,
  escape, interact-outside, auto focus and animation end; callers run first and
  a prevented event stops the internal logic.
- Submenu panels receive the nested popover's data/style/id/extra events, honour
  isKeyboardDismissDisabled without closing the parent level or a modal, and
  forward shouldCloseOnInteractOutside.
- A standalone Menu provides its own content-attribute channel so the
  accessible name/description land on the real role=menu node.
This commit is contained in:
maoyingjie
2026-10-24 23:42:05 +08:00
parent 53b4639b0e
commit b474a63303
12 changed files with 465 additions and 54 deletions
+13
View File
@@ -105,3 +105,16 @@ default、with-icons、with-descriptions、with-disabled-items、with-sections
能力清单同步落地:`disallowEmptySelection`、`escapeKeyBehavior`、`shouldFocusWrap`、`autoFocus`、`shouldCloseOnSelect`(菜单级)、`close` 事件、`empty` 插槽、`isKeyboardDismissDisabled`、`shouldCloseOnInteractOutside`、`Trigger`/`Popover` 作用域插槽(`{isOpen}` / `{isEntering,isExiting,placement}`)、`placement/offset/crossOffset/shouldFlip/containerPadding`(复用本库 Popover 取值);`items` 用 `v-for`、`renderEmptyState` 用 `empty` 插槽表达;子菜单 `delay` 与子菜单 `side/align` 作为底座固定值写入「上游差异」。
独立浏览器消费:夹具随仓库提供于 `tests/package/b01-consumer-app/`(选择长菜单、三级子菜单、Modal 内菜单、独立 Menu、链接项),tarball 安装后 esbuild 打包 + 静态服务,上述 R1/R2/R8/R11 结论均来自该页面实测。`consume-b01-menu-dropdown.mjs` 仍只做导出/CSS 存在性检查,真实挂载以该夹具为准。
## 整批清单二次返修(2026-10-24)
按 [B01 整批清单返修复核](B01-complete-review-2.md) 收口剩余 4 类 7 项,探针扩至 **20/20**。
| ID | 修复 | 证据 |
| --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| R4 | `Menu` 只暴露菜单级原始策略(未设置为 `undefined`),`MenuItem.shouldClose()` 按「条目 → 菜单布尔/函数 → 按条目模式默认(动作/单选关闭、多选保持)」解析 | 探针三项(默认动作关闭、single+false、multiple+true);浏览器复验默认动作点击后 `aria-expanded=false`;新增 Section 模式优先级回归 |
| R6 | 根面板 `onKeydown`/`onEscapeKeyDown`/`onInteractOutside`/`onOpenAutoFocus`/`onAnimationend` 统一为「调用方 + 内部」数组链,调用方先执行,`defaultPrevented` 后内部跳过 | 探针「root popover preserves a user keydown callback」;新增四类事件与取消 Escape 回归 |
| R9 | 子面板透传 `data-*`/`style`/`id`/其他事件;`isKeyboardDismissDisabled` 阻止本层与父层/Modal 关闭;`shouldCloseOnInteractOutside` 接到子面板 outside 链路 | 探针两项(data/style 保留、Esc 不关闭);新增「禁止 Esc 时父层仍开」回归 |
| R8 | 独立 `Menu` 自持内容属性通道,名称/描述落到真正的 `role="menu"` 节点 | 探针「standalone Menu keeps its own accessible name」 |
回归:**72 文件 / 928 项**通过;typecheck、Prettier、`git diff --check` 通过;独立 tarball 消费重跑通过;浏览器复验默认动作关闭、三级子菜单逐层 Esc 与 Portal/Modal 既有路径。