fix(collection): make virtual window, reveal and confirmation honest
- Give the verification instance a real constrained scroll owner and a row height that matches the rendered row, and feed ListBox the full data schema so a row that was never mounted can still be filtered. - Move reveal validity in front of every side effect and re-check after each await: latest token, mounted component, enabled row, still visible and open. Waiting for a virtualized row now requires connected DOM, not just a registration, and closing the collection cancels pending work. - Reconcile the shared active key reactively: a removed, disabled, filtered-out or closed active row is cleared, while the accepted value stays as history. The composite re-validates before confirming, so a stale candidate cannot be submitted. - Read the caller's cancellation before the focus guard so a plain virtual-focus press keeps its pressed state, and use one nested-interactive boundary for both pointer and click, covering contenteditable variants and custom roles. - Render the empty channel for static slot collections too, keeping hidden members mounted. Adds the seven-case round-two probe and twelve regressions; browser checks cover the real virtual window, remote filtering, viewport-contained navigation and filter restoration.
This commit is contained in:
@@ -217,3 +217,31 @@ export interface CollectionOwner extends CollectionView {
|
||||
- 真实系统 IME(自动化后端无法产生系统组合输入,只有 `CompositionEvent`/`isComposing` 覆盖)。
|
||||
- 读屏软件播报。
|
||||
- 验证夹具自身的滚动容器:库里 `.hv-list-box` 的 `overflow: clip` 会盖掉示例给的 `overflow-y-auto`(夹具与公共样式的组合问题,不影响协议;B02b 的 ComboBox 用 Popover 容器承载滚动,需单独核对)。这一条已记录,不当作已解决。
|
||||
|
||||
## 10. B02a 第二轮复核返修(五类问题,第三轮)
|
||||
|
||||
按 [第二轮返修说明](/private/tmp/B02a-round2-review.md) 集中修复,独立提交。复核探针固化为 `tests/b02a-round2-review.probe.test.ts`(7 项,已加入 `test:unit`),从全红转为全绿;自有回归增至 `tests/collection-filter-virtual.test.ts` 26 项。
|
||||
|
||||
| # | 问题 | 修复 |
|
||||
| --- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| R1 | 虚拟化验证不成立:容器 `overflow: clip`、`max-h` 未生效、40 行全挂载、远端活动项在视口外;夹具传 `text` 而完整数据读 `textValue`,未挂载项无法被过滤 | 验证页给自己的虚拟实例**显式内联**受限滚动容器(`max-height: 144px; overflow-y: auto`,不全局改 ListBox 样式),实测 `clientHeight 144 / scrollHeight 1448 / overflow auto`;行高契约统一为 `rowHeight=36`(与 `.hv-list-box-item` 的 36px 一致),实测行高 36;夹具新增 `listItems` 映射(`id/textValue/isDisabled`)作为 `items` 传入,100 条数据中未挂载的 `Row 99` 可被过滤(原来回退空文本失败) |
|
||||
| R2 | 请求令牌在滚动之后才检查,过期请求仍滚一次 | `revealRow(key, valid)` 把有效性检查推进到**每个副作用之前**与每个 await/帧之后;`isValid` 覆盖最新令牌、未卸载、未禁用、仍在可见集合、且 `owner.isOpen?.() !== false`;虚拟化等待改为「已注册且 `element.isConnected`」的有界帧轮询;新增 `CollectionView.isOpen`(关闭即取消) |
|
||||
| R3 | 动态移除/禁用的活动项仍可提交 | ListBox 新增响应式协调:虚拟焦点下活动 key 不再属于可见且启用的集合、或集合已关闭时,把共享 `activeKey` 清空(不自行另选,选择权留给组合体);夹具的确认动作再校验「仍在 eligible 且 open」,通过才发 `proposal`/接受;已接受值作为历史保留并记住接受时的标签 |
|
||||
| R4 | 保焦点破坏按下态;嵌套控件仍触发父选项;`contenteditable` 判断不全 | `onPointerdown` 先读调用方是否已取消,再调焦点守卫,合法按下态得以保留;抽出 `NESTED_INTERACTIVE` 选择器(含 `a[href]`、`summary`、`[role=button/link/menuitem/checkbox/radio/switch/tab/option]`、`[contenteditable]:not([contenteditable="false"])`,覆盖 `""`/`true`/`plaintext-only`)并**同时用于 pointerdown 与 click**:来自嵌套控件的点击不再激活父选项,控件自己的事件不被拦截 |
|
||||
| R5 | 静态插槽集合没有过滤空状态 | ListBox 模板改为:静态分支也渲染 `empty` 通道(`visibleIsEmpty` 且集合已稳定,避免首帧误报),隐藏成员仍保留以留住元数据;`items` 非虚拟/虚拟两种模式继续用可见集合判空 |
|
||||
|
||||
### 10.1 浏览器证据(5182,Chromium/IAB,40 行虚拟实例)
|
||||
|
||||
- 打开后:`clientHeight 144`、`scrollHeight 1448`、`overflow-y auto`、`max-height 144px`、**挂载行 10**(4 可见 + overscan),行高 **36**,虚拟内容总高 1440。
|
||||
- `ArrowUp` 从第 0 行回绕到第 39 行:`scrollTop 0 → 1304`、挂载行 8、**活动行位于受限视口内**(相对顶部 104,viewport 144),焦点仍在输入框。
|
||||
- 输入“第 39”:挂载行 **1**、`scrollHeight 44`、活动项为“第 39 行”、焦点仍在输入框(未挂载过的远端项也能命中)。
|
||||
- 清空过滤:挂载行恢复 10、`scrollHeight 1448`、`scrollTop 0`;手动 `scrollTo(0)` 后 `aria-activedescendant` 仍指向已挂载、未过滤的 `role="option"`。
|
||||
|
||||
### 10.2 本轮验证汇总
|
||||
|
||||
`pnpm typecheck` 通过;`pnpm test` **77 文件 / 1024 项**通过(26 项自有 + 5 项第一轮探针 + 7 项第二轮探针,其余为既有 ListBox/Select 等回归);`pnpm build:docs`、`pnpm build:playground`、Prettier、`git diff --check` 通过。
|
||||
|
||||
### 10.3 仍未验证
|
||||
|
||||
- 真实系统 IME 与读屏软件(自动化后端无法产生系统组合输入;本轮不新增门槛)。
|
||||
- 指针按下态的浏览器原生序列(自动化只能给出 click,`pointerdown` 单独按下态由 jsdom 覆盖);嵌套控件点击隔离同样以 jsdom 覆盖(浏览器侧需注入 DOM,未做)。
|
||||
|
||||
Reference in New Issue
Block a user