mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
fix(combo-box): fix typing when refocusing input
Fixes a bug where the input `value` is immediately reset when re-focusing the input. The `value` resetting is necessary to support programmatically clearing the value, but it should only execute if the input is not currently focused.
This commit is contained in:
parent
0e1177f398
commit
9e3d83031e
2 changed files with 27 additions and 3 deletions
|
@ -127,6 +127,24 @@ describe("ComboBox", () => {
|
|||
const options = screen.getAllByRole("option");
|
||||
expect(options).toHaveLength(1);
|
||||
expect(options[0]).toHaveTextContent("Email");
|
||||
|
||||
await user.clear(input);
|
||||
expect(input).toHaveValue("");
|
||||
expect(screen.getAllByRole("option")).toHaveLength(3);
|
||||
|
||||
await user.click(document.body);
|
||||
expect(input).not.toHaveFocus();
|
||||
|
||||
await user.keyboard("{Tab}");
|
||||
expect(input).toHaveFocus();
|
||||
|
||||
await user.type(input, "a");
|
||||
await user.click(screen.getAllByRole("option")[1]);
|
||||
expect(input).toHaveValue("Email");
|
||||
|
||||
await user.click(document.body);
|
||||
expect(input).not.toHaveFocus();
|
||||
expect(screen.queryByRole("option")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should handle disabled items", async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue