fix: complete submenu panel ARIA, focus and event passthrough

- Submenu panel name priority is explicit aria-label > menu content channel >
  this instance's trigger; an explicit label drops the id reference so it cannot
  be shadowed.
- openAutoFocus and animationend chain with the caller's handlers like keydown
  and interact-outside, so caller callbacks run and can cancel.
- The panel loop falls back to the menu-level shouldFocusWrap and is always
  passed as a boolean: an undefined -> true update is dropped by the base prop
  chain, so the menu policy never applied.
- Add a jsdom CSSOM polyfill for CSS.escape via vitest setupFiles; the
  animationend test no longer raises an unhandled error.
This commit is contained in:
maoyingjie
2026-10-25 00:01:24 +08:00
parent b474a63303
commit 2e4b376537
9 changed files with 223 additions and 20 deletions
+13
View File
@@ -118,3 +118,16 @@ default、with-icons、with-descriptions、with-disabled-items、with-sections
| R8 | 独立 `Menu` 自持内容属性通道,名称/描述落到真正的 `role="menu"` 节点 | 探针「standalone Menu keeps its own accessible name」 |
回归:**72 文件 / 928 项**通过;typecheck、Prettier、`git diff --check` 通过;独立 tarball 消费重跑通过;浏览器复验默认动作关闭、三级子菜单逐层 Esc 与 Portal/Modal 既有路径。
## b474a63 复核返修(2026-10-24)
按 [b474a63 复核记录](B01-b474a63-review.md) 收口 R9 子面板透传的 3 个分支与测试环境异常,探针 **23/23**。
| 项 | 修复 | 证据 |
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| 子面板 ARIA 被覆盖 | 名称优先级:面板显式 `aria-label` > Menu 内容通道 > 实例触发器 id;有 `aria-label` 时移除 `aria-labelledby`,避免 id 引用压过显式名称 | 探针「submenu keeps a directly supplied panel accessible name」 |
| 子面板 `openAutoFocus` 被覆盖 | 与 `onKeydown`/`onInteractOutside`/`onAnimationend` 一样改为「调用方 + 内部」数组链,调用方先执行并按 `defaultPrevented` 取消 | 探针「submenu preserves a caller's openAutoFocus callback」 |
| 子菜单 `shouldFocusWrap` 未生效 | 面板 `loop` 恢复回退到菜单级 `contentAttrs.loop`;并统一传布尔值——实测 `undefined → true` 的更新会被底座属性链丢弃,`false → true` 才生效 | 探针「submenu respects the menu's shouldFocusWrap navigation」 |
| 测试环境 `CSS.escape` 缺失 | 新增 `tests/setup/cssom.ts`,仅在缺失时补 `CSS.escape` 并注册到 `vitest.config.ts` 的 `setupFiles`;不关错误检查、不改产品行为 | 单跑与全量均无 Unhandled Errors |
回归:**72 文件 / 931 项**通过、无未捕获错误;typecheck、Prettier、`git diff --check` 通过。