fix(pickers): rework B02 against the public review
Restore native clearing, unify the form/field protocol with the other choice families (per-key entries, disabled and removed keys omitted, shared form owner), synchronise ComboBox text by key identity, keep filtering out of open composition sessions, and stop stealing focus when a controlled close is rejected. Also merge caller refs/ARIA/disabled, implement asChild, autoFocus and ComboBox variant, use a locale-aware base matcher, and put the indicator class and slot on the icon element the ported CSS selects.
This commit is contained in:
@@ -175,15 +175,45 @@ describe("ComboBox docs and demos", () => {
|
||||
mounted.push(wrapper);
|
||||
await nextTick();
|
||||
await settle();
|
||||
const hidden = [
|
||||
...(wrapper.element as HTMLElement).querySelectorAll<HTMLInputElement>(
|
||||
'input[type="hidden"][name]',
|
||||
),
|
||||
const form = (wrapper.element as HTMLElement).matches("form")
|
||||
? (wrapper.element as HTMLFormElement)
|
||||
: (wrapper.element as HTMLElement).querySelector("form")!;
|
||||
// Nothing selected yet: an empty picker submits no entry at all.
|
||||
expect(new FormData(form).has("animal")).toBe(false);
|
||||
|
||||
for (const input of [
|
||||
...form.querySelectorAll<HTMLInputElement>('[data-slot="input"]'),
|
||||
]) {
|
||||
input.focus();
|
||||
await settle();
|
||||
input.dispatchEvent(
|
||||
new KeyboardEvent("keydown", {
|
||||
key: "ArrowDown",
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
}),
|
||||
);
|
||||
await settle();
|
||||
input.dispatchEvent(
|
||||
new KeyboardEvent("keydown", {
|
||||
key: "Enter",
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
}),
|
||||
);
|
||||
await settle();
|
||||
}
|
||||
|
||||
const data = new FormData(form);
|
||||
const inputs = [
|
||||
...form.querySelectorAll<HTMLInputElement>('[data-slot="input"]'),
|
||||
];
|
||||
expect(hidden.map((input) => input.name).sort()).toEqual([
|
||||
"animal",
|
||||
"animal-text",
|
||||
]);
|
||||
// Both pickers confirmed the same row: key mode submits the id, text mode
|
||||
// the label — never a comma-joined string.
|
||||
expect(data.get("animal")).toBe("cat");
|
||||
expect(data.get("animal-text")).toBe("猫");
|
||||
expect(data.getAll("animal")).toEqual(["cat"]);
|
||||
expect(inputs.map((input) => input.value)).toEqual(["猫", "猫"]);
|
||||
wrapper.unmount();
|
||||
mounted.pop();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user