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
+6 -6
View File
@@ -295,7 +295,7 @@ Dropdown 使用 Menu、MenuItem 与 MenuSection 作为底层组件。以下类
| `collisionPadding` | `number` | — | **底层扩展**:覆盖 `containerPadding`。 |
| `loop` | `boolean` | — | **底层扩展**:焦点循环。 |
默认插槽会收到 `{ isEntering, isExiting, placement }`。
默认插槽会收到 `{ isEntering, isExiting, placement }`。`onKeydown`/`onEscapeKeyDown`/`onInteractOutside`/`onOpenAutoFocus`/`onAnimationend` 与调用方处理器按 Vue 数组语义合并,调用方先执行,`preventDefault()` 后内部逻辑不再动作。
### DropdownMenu
@@ -367,11 +367,11 @@ Dropdown 使用 Menu、MenuItem 与 MenuSection 作为底层组件。以下类
### DropdownSubmenuTrigger
| Slots / Props | 说明 |
| ------------- | --------------------------------------------------------------------------------------------------------------------- |
| 默认插槽 | 第一个子节点是触发条目,其余子节点渲染进子菜单内容 |
| `class`/ARIA | 合并到触发条目元素上 |
| 面板参数 | 嵌套 `DropdownPopover` 的 `offset`/`crossOffset`/`shouldFlip`/`containerPadding`/`loop`/`to`/`class` 会传给子菜单面板 |
| Slots / Props | 说明 |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 默认插槽 | 第一个子节点是触发条目,其余子节点渲染进子菜单内容 |
| `class`/ARIA | 合并到触发条目元素上 |
| 面板参数 | 嵌套 `DropdownPopover` 的 `offset`/`crossOffset`/`shouldFlip`/`containerPadding`/`loop`/`to`、`class`/`style`/`id`/`data-*`/ARIA 与事件都会传给子菜单面板;`isKeyboardDismissDisabled` 为真时 Esc 既不关子层也不关父层,`shouldCloseOnInteractOutside` 返回 `false` 时外部交互不关闭 |
每层子菜单独立持有 open 状态并各自 Portal;焦点在子菜单内按 Esc 只关闭当前层,焦点回到该层触发器。子菜单的 `side`/`align` 由底层固定为「贴着父项向右展开」(RTL 反向),只有偏移与碰撞参数可调。