fix: portal dropdown surfaces and close the review capability gaps
- Root and submenu surfaces render through the dropdown portal with the overlay z-index, so clipping/isolation ancestors no longer cut the menu; panel height is capped by the floating available height and the animation origin maps the real transform origin. - Standalone Menu is a static in-flow list: no scroll lock, no outside pointer blocking, no floating placement and no focus stealing. - Selection ownership is isolated per level: section disabled keys add to the menu list, and a nested Menu resets the section owner. - closeOnSelect resolves item > menu policy > per-mode default for selection items; actions and radio items close, checkboxes stay open. - Business keys no longer become DOM ids (instance ids + data-key), and submenu surfaces label themselves from the real trigger. - Long-press keydown runs the caller's handlers first and only opens when not cancelled; submenu panels merge caller keydown with the internal Escape. - Link items render a real anchor, aria labels land on the role=menu node, submenu panels forward placement/offset/collision props and caller attrs, and the popover provides the default Surface variant. - Wrapper parts declare real props/emits, plus the missing official capability props (disallowEmptySelection, escapeKeyBehavior, shouldFocusWrap, autoFocus, shouldCloseOnSelect, close, empty slot, isKeyboardDismissDisabled, shouldCloseOnInteractOutside, placement/offset family, scoped slots). - Ship an independent consumer fixture for browser-level verification.
This commit is contained in:
@@ -82,3 +82,26 @@ default、with-icons、with-descriptions、with-disabled-items、with-sections
|
||||
按官方 `dropdown.mdx` 与 17 个官方演示逐条对照,问题清单、证据与逐项状态见 [B01 忠实度审计](B01-fidelity-audit.md)。本轮修掉 25 项(禁用态、进出动画、单 `role="menu"`、条目 id 与子菜单 `aria-labelledby`、自定义触发器可聚焦、触发器 inline-flex 冲突、`hasSubmenu` 来源、Section 标题关联、Render Props、`data-focused` 等交互状态、class 合并、子菜单指示器图标、演示 27 处 `Kbd slot="keyboard"`、官方图标与文档页重写),并保留 6 项须记录的差异:链接型菜单项不支持、子菜单悬停延迟固定 100ms、无 `disallowEmptySelection` 等官方 props、长按键盘语义、`DropdownRoot` 包裹元素、`Selection`→`MenuKey[]` 适配。
|
||||
|
||||
回归:`tests/b01-menu-dropdown.test.ts` **27/27**、`tests/b01-review.probe.test.ts` **7/7**,完整 **71 文件 / 897 项**;typecheck、build:docs、Prettier 通过;浏览器 5181 实测禁用态、进出动画、图标居中、自定义触发器键盘打开、`data-focused` 背景、单 `role="menu"` 与 `kbd[slot="keyboard"]`。
|
||||
|
||||
## 整批复核返修(2026-10-24)
|
||||
|
||||
按 [B01 整批复核与统一返修清单](B01-complete-review.md) 处理 R1–R12 与能力清单。新增探针 `tests/b01-complete-review.probe.test.ts` **13/13**、类型正例 `tests/package/b01-wrapper-props-review.ts` 通过。
|
||||
|
||||
| ID | 实现位置 | 测试 / 浏览器证据 | 文档 |
|
||||
| --- | --------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
||||
| R1 | `DropdownPopover` / `DropdownSubmenuTrigger` 接入 `DropdownMenuPortal`(`to` 可配);`.hv-dropdown__popover` 增加 `z-index: var(--z-index-overlay)` | 单测:面板不在 `contain/isolation` 祖先内;浏览器:面板父节点为 popper 包装层且位于 body,rect 57–383(视口 709),首末项均可见,z-index 100000;Modal 内面板在 backdrop 之后挂载(DOM 顺序 4 > 3),Esc 先关菜单再关 Modal,关闭后 body 样式清空、焦点回触发器 | 「弹层默认通过 Portal 挂载…」段 + DropdownPopover `to` 行 |
|
||||
| R2 | `Menu` 独立路径改为 `modal: false` + 非 Portal + `data-static` + 阻止 auto focus;`.hv-dropdown__popover[data-static]` 的包装层用静态定位 | 探针 + 单测;浏览器:内联菜单 `body` 无内联样式、包装层 `position: static`、焦点留在 body、`role=menuitem` | 「独立 Menu」小节 |
|
||||
| R3 | `MenuSection` 的禁用列表与菜单级叠加;`Menu` 提供 `menuSectionContextKey = null` 重置作用域 | 探针两项 + 单项「Section 下新 Menu 不继承 owner」 | DropdownSection 表 + 「分组内再嵌套的 Menu 会重置选择作用域」 |
|
||||
| R4 | `MenuItem.shouldClose()`:条目 `closeOnSelect` > 菜单 `shouldCloseOnSelect` > 按模式默认(多选保持打开) | 探针两项(single+false 保持、multiple+true 关闭) | DropdownItem `closeOnSelect` 与 DropdownMenu `shouldCloseOnSelect` 行 |
|
||||
| R5 | `MenuItem` 用实例级 `useId()` 作 DOM id,业务 key 只进 `data-key`/选择;子菜单 `aria-labelledby` 直接指向本实例触发器 | 探针(0 与 "0" 不重复)+ 单测(id 唯一、`data-key` 保持业务 key) | DropdownItem `id` 行 + 上游差异条 |
|
||||
| R6 | 长按键:Enter/Space 的用户 `keydown` 先执行(capture 链),内部在 `defaultPrevented` 时才跳过打开;基准触发器的 toggle 在本次事件内被挂起 | 探针「取消的 keydown 不打开」+ 单测「Enter/Space 只切换一次」 | DropdownRoot 长按段 |
|
||||
| R7 | `MenuItem.href/target/rel/download/hrefLang/referrerPolicy` → 渲染真实 `<a>`;禁用项阻止导航 | 探针 + 单测(标签为 A、href/target 保留、action 仍触发、禁用时不导航) | DropdownItem 链接行 |
|
||||
| R8 | `Menu` 把 `aria-label`/`aria-labelledby`/`aria-describedby` 通过内容通道写到真正的 `role="menu"` 节点 | 探针(`[role=menu]` 带 `File actions`)+ 浏览器(`水果操作`) | 无障碍段 + DropdownMenu 说明 |
|
||||
| R9 | 子菜单面板接收嵌套 `DropdownPopover` 的 `offset/crossOffset/shouldFlip/containerPadding/loop/to/class/aria/事件`;用户 `keydown` 与内部 Escape 合并 | 探针(keydown 一次)+ 单测(panel class、keydown) | DropdownSubmenuTrigger「面板参数」行 |
|
||||
| R10 | `DropdownPopover` 提供 `surfaceContextKey` 的 `default` 变体 | 探针(Surface secondary 下读回 default) | 无(行为与官方一致) |
|
||||
| R11 | `origin` 改用 `--reka-dropdown-menu-content-transform-origin`;`max-height` 用 `--reka-dropdown-menu-content-available-height` | 浏览器:`transform-origin: 30px 0px`(真实浮动原点)、`max-height: 640px` 与 `overflow-y: auto` | 「面板高度受…约束」段 |
|
||||
| R12 | `DropdownItem`/`DropdownMenu`/`DropdownSection` 补齐真实 props/emits,`DropdownSubmenuTriggerProps` 由组件推导 | `tests/package/b01-wrapper-props-review.ts` 在仓库与独立 tarball 中均通过(bundler + NodeNext) | 各部件 API 表 |
|
||||
|
||||
能力清单同步落地:`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 存在性检查,真实挂载以该夹具为准。
|
||||
|
||||
Reference in New Issue
Block a user