fix: reveal Select focus after floating positioning

This commit is contained in:
maoyingjie
2026-10-23 22:47:36 +08:00
parent 2b569451b6
commit 50f561a758
9 changed files with 176 additions and 4 deletions
+19
View File
@@ -694,3 +694,22 @@ it("keeps locally disabled options out of the native submission even with explic
expect(data()).toEqual([]);
expect(w.get('[data-slot="select-value"]').text()).toBe("Alpha");
});
it("reveals only the currently focused owned option after popup positioning starts", async () => {
const w = fixture(`<Select default-value="last">${content}</Select>`);
await trigger(w).trigger("click");
await flushPromises();
const active = option(3);
const reveal = vi.fn();
active.scrollIntoView = reveal;
const popup = document.querySelector<HTMLElement>(
'[data-slot="select-popover"]',
)!;
popup.dispatchEvent(new Event("animationstart", { bubbles: true }));
expect(reveal).toHaveBeenCalledOnce();
active.dispatchEvent(new Event("animationstart", { bubbles: true }));
expect(reveal).toHaveBeenCalledOnce();
(trigger(w).element as HTMLElement).focus();
popup.dispatchEvent(new Event("animationstart", { bubbles: true }));
expect(reveal).toHaveBeenCalledOnce();
});