feat(collection): add optional filtering and virtual focus for composite pickers

ComboBox and Autocomplete need two capabilities the collection protocol did not
express: filtering a collection by an external input value, and keeping DOM focus
in the composite's input while an active option is tracked for
aria-activedescendant.

Both are opt-in members on CollectionOwner plus optionId/reveal on the owned
collection. Standalone ListBox and Select provide none of them and keep their
previous behaviour: DOM focus still moves into the list, one roving tab stop, no
row filtering.

Filtered rows stay mounted with data-filtered (display:none) so their text and
accepted selection survive; only display, aria positions and keyboard navigation
see the visible subset. Under virtual focus the list never takes DOM focus,
never exposes a roving tab stop, and leaves keyboard handling to the composite;
reveal() scrolls a virtualized window and waits for the row to mount before the
composite reads its id.

Includes the playground verification page, a ten-case suite and the B02a section
of the migration report.
This commit is contained in:
maoyingjie
2026-10-25 14:53:49 +08:00
parent fa73cafd20
commit 1b972a78ba
11 changed files with 849 additions and 30 deletions
+5
View File
@@ -13,6 +13,10 @@ const animationLab =
typeof window !== "undefined" &&
new URLSearchParams(window.location.search).has("overlay-animation");
import OverlayLab from "./OverlayLab.vue";
import FilterVirtualLab from "./FilterVirtualLab.vue";
const filterVirtualLab =
typeof window !== "undefined" &&
new URLSearchParams(window.location.search).has("filter-virtual");
import OverlayComponentsLab from "./OverlayComponentsLab.vue";
const componentsLab =
typeof window !== "undefined" &&
@@ -36,6 +40,7 @@ function save() {
<OverlayAnimationLab v-else-if="animationLab" />
<OverlayComponentsLab v-else-if="componentsLab" />
<OverlayLab v-else-if="overlayLab" />
<FilterVirtualLab v-else-if="filterVirtualLab" />
<div v-else class="lab" :data-theme="dark ? 'dark' : 'light'">
<header>
<a class="wordmark" href="#">
+41
View File
@@ -0,0 +1,41 @@
<script setup lang="ts">
/**
* B02a verification page: proves the optional collection-owner protocol
* (filter + virtual focus) that ComboBox and Autocomplete will consume.
* This is a harness, not a public component.
*/
import FilterVirtualCombobox from "../../../packages/vue/tests/fixtures/FilterVirtualCombobox.vue";
</script>
<template>
<main
class="lab"
data-theme="light"
style="padding: 32px; display: grid; gap: 32px"
>
<header style="display: grid; gap: 8px">
<h1 style="font-size: 20px; font-weight: 600">B02a 过滤与虚拟焦点验证</h1>
<p style="font-size: 13px; color: var(--muted)">
输入“狗”或“鼠”过滤列表;方向键只在可见行之间移动;焦点始终留在输入框,高亮行由
aria-activedescendant 指向。第二个实例的父级拒绝选择提案。
</p>
</header>
<section style="display: grid; gap: 8px">
<h2 style="font-size: 15px; font-weight: 600">1. 过滤 + 虚拟焦点</h2>
<FilterVirtualCombobox />
</section>
<section style="display: grid; gap: 8px">
<h2 style="font-size: 15px; font-weight: 600">
2. 受控拒绝(选择提案不生效)
</h2>
<FilterVirtualCombobox :accept-selection="false" />
</section>
<section style="display: grid; gap: 8px">
<h2 style="font-size: 15px; font-weight: 600">3. 不过滤(对照)</h2>
<FilterVirtualCombobox :filter-enabled="false" />
</section>
</main>
</template>