Skip to content

fix(combobox): open the component when typing within it #9543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,35 @@ describe("calcite-combobox", () => {
openClose(simpleComboboxHTML);
});

it("should open the combobox when typing within the input", async () => {
const page = await newE2EPage({
html: html`
<calcite-combobox id="myCombobox">
<calcite-combobox-item value="Raising Arizona" text-label="Raising Arizona"></calcite-combobox-item>
<calcite-combobox-item value="Miller's Crossing" text-label="Miller's Crossing"></calcite-combobox-item>
<calcite-combobox-item value="The Hudsucker Proxy" text-label="The Hudsucker Proxy"></calcite-combobox-item>
<calcite-combobox-item value="Inside Llewyn Davis" text-label="Inside Llewyn Davis"></calcite-combobox-item>
</calcite-combobox>
`,
});

const combobox = await page.find("calcite-combobox");
const input = await page.find("calcite-combobox >>> input");
const items = await page.findAll("calcite-combobox-item");
expect(await combobox.getProperty("open")).toBe(false);
await input.focus();
await page.waitForChanges();

await input.type("Arizona");
await page.waitForChanges();

expect(await combobox.getProperty("open")).toBe(true);
expect(await items[0].isVisible()).toBe(true);
expect(await items[1].isVisible()).toBe(false);
expect(await items[2].isVisible()).toBe(false);
expect(await items[3].isVisible()).toBe(false);
});

it("filtering does not match property with value of undefined", async () => {
const page = await newE2EPage({
html: html`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ export class Combobox
const value = (event.target as HTMLInputElement).value;
this.text = value;
this.filterItems(value);
this.open = value.length > 0;
if (value) {
this.activeChipIndex = -1;
}
Expand Down
Loading