From 50ad3ca1807bcfcbfc1a028d5ed8e8906d387cd5 Mon Sep 17 00:00:00 2001 From: maoyingjie Date: Sun, 25 Oct 2026 16:28:33 +0800 Subject: [PATCH] fix(collection): close the six review gaps in filtering and virtual focus - Keep the composite input focused on real pointer presses: cancel the default focus transfer for plain row presses only, leaving nested controls and already cancelled callers alone. - Drive the virtual window, total height, reveal index and aria positions from the visible subset, and render the empty channel when filtering removes every row. Non-virtualized rows stay mounted and are hidden, so their text and accepted selection survive. - Scroll mounted rows for reveal/focus outside virtualization, wait for a virtualized row to mount (frame-based, bounded), and drop reveal requests that filtering, closing or unmounting made obsolete. - Stop overwriting caller `hidden`: mergeProps deletes an earlier key when a later value is undefined, so the filter now only adds `hidden` when the caller did not set it. - Share keyboard modality through an optional `keyboardIntent` ref so a pointer press no longer leaves the active row without data-focus-visible. - Give the verification harness instance-unique ids and derive aria-activedescendant from open state, mounted id and filter visibility. Adds the reviewer probe plus eight regressions, and a virtualized harness instance for the browser smoke of filtering plus window/height/positions. --- apps/playground/src/FilterVirtualLab.vue | 14 ++ docs/migrations/B02-combobox-autocomplete.md | 30 ++++ package.json | 2 +- .../vue/src/components/collection/owner.ts | 6 + .../vue/src/components/list-box/ListBox.vue | 117 +++++++++----- .../src/components/list-box/ListBoxItem.vue | 32 +++- .../tests/fixtures/FilterVirtualCombobox.vue | 97 ++++++++++-- tests/b02a-review.probe.test.ts | 123 +++++++++++++++ tests/collection-filter-virtual.test.ts | 145 ++++++++++++++++++ 9 files changed, 511 insertions(+), 55 deletions(-) create mode 100644 tests/b02a-review.probe.test.ts diff --git a/apps/playground/src/FilterVirtualLab.vue b/apps/playground/src/FilterVirtualLab.vue index 9d87cfa..4b5a52e 100644 --- a/apps/playground/src/FilterVirtualLab.vue +++ b/apps/playground/src/FilterVirtualLab.vue @@ -5,6 +5,11 @@ * This is a harness, not a public component. */ import FilterVirtualCombobox from "../../../packages/vue/tests/fixtures/FilterVirtualCombobox.vue"; + +const manyOptions = Array.from({ length: 40 }, (_, index) => ({ + id: `row-${index}`, + text: `第 ${index} 行`, +})); diff --git a/docs/migrations/B02-combobox-autocomplete.md b/docs/migrations/B02-combobox-autocomplete.md index 72cc68c..a00ce73 100644 --- a/docs/migrations/B02-combobox-autocomplete.md +++ b/docs/migrations/B02-combobox-autocomplete.md @@ -187,3 +187,33 @@ export interface CollectionOwner extends CollectionView { - 是否接受把 `optionId`/`reveal` 放在 `OwnedCollection`(集合侧实现)而不是 `CollectionOwner`(组合体实现);`reveal` 的语义是“滚动并等待挂载”,不改变选择。 - `data-filtered` 采用 CSS `display:none`(而非卸载)以保住文本与选择;如果集成人更希望卸载,需要同时提供“完整数据”的独立来源,否则被过滤的已选项会失去标签。 - `virtualFocus` 下 ListBox 完全不处理键盘(`keydown/keyup` 提前返回);组合体必须自己实现方向键、Enter、Esc、Tab 与 IME 守卫。 + +## 9. B02a 复核返修(六类问题,第二轮) + +按 [B02a 复核](/private/tmp/B02a-review.md) 集中修复,独立提交。复核探针已固化到 `tests/b02a-review.probe.test.ts` 并加入 `test:unit`,5 项从全红转为全绿;本轮再加 8 项自有回归,合计 `tests/collection-filter-virtual.test.ts` 18 项。 + +| # | 问题 | 修复 | 证据 | +| --- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 1 | 真实指针点击丢输入焦点(落到 body) | `ListBoxItem` 在虚拟焦点下对 `pointerdown` 与 `mousedown` 的默认焦点转移做 `preventDefault`;嵌套交互控件(`button/a/input/select/textarea/[contenteditable]`)例外;调用方已 `preventDefault` 时不再插手;pointerdown 的按下态逻辑保留 | 浏览器:填“狗”后**真实点击**选项,`document.activeElement` 仍为 input,已选“狗”;单测断言 `pointerdown`/`mousedown` 均 `defaultPrevented`,嵌套 `