Skip to content

Commit

Permalink
fix(combobox): prevent spacebar from opening the menu when focused on…
Browse files Browse the repository at this point in the history
… chip's close button
  • Loading branch information
Elijbet committed Mar 22, 2024
1 parent 2b7a3d2 commit 93f8817
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,7 @@ describe("calcite-combobox", () => {

const wrapper = await page.find("calcite-combobox >>> .wrapper");
const close = await wrapper.find("calcite-chip >>> .close");
await close.click();
await close.press(" ");
await page.waitForChanges();

const remainingChips = await page.findAll("calcite-combobox >>> calcite-chip");
Expand Down
11 changes: 6 additions & 5 deletions packages/calcite-components/src/components/combobox/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -683,15 +683,16 @@ export class Combobox
case " ":
if (!this.textInput.value) {
if (!this.open) {
this.open = true;
this.shiftActiveItemIndex(1);
if (event.composedPath().find((el: HTMLElement) => el.tagName === "CALCITE-CHIP")) {
event.preventDefault();
} else {
this.open = true;
this.shiftActiveItemIndex(1);
}
}
event.preventDefault();
}

if (event.composedPath().find((el: HTMLElement) => el.tagName === "CALCITE-CHIP")) {
event.preventDefault();
}
break;
case "Home":
if (!this.open) {
Expand Down

0 comments on commit 93f8817

Please sign in to comment.