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
@@ -56,6 +56,11 @@ export interface ListBoxContext {
activate: (key: ListBoxKey, event: MouseEvent | KeyboardEvent) => void;
focus: (key: ListBoxKey) => Promise<void>;
virtualized: () => boolean;
/** Keep DOM focus outside the collection; only the active key moves. */
virtual: () => boolean;
/** Whether the owner filter currently shows this record. */
visible: (key: ListBoxKey) => boolean;
optionId: (key: ListBoxKey) => string | undefined;
restoreFocus: () => void;
position: (key: ListBoxKey) => { index: number; size: number } | undefined;
}