Skip to content

Commit

Permalink
fix(combobox): prevents navigation list with Space key (#7505)
Browse files Browse the repository at this point in the history
**Related Issue:** #6387 

## Summary

This prevents `Space` key navigating combobox list when opened.
  • Loading branch information
anveshmekala committed Aug 11, 2023
1 parent e1aee99 commit 58e2ff2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ describe("calcite-combobox", () => {
expect(await page.evaluate(() => document.activeElement.id)).toBe("myCombobox");
});

it(`Space opens dropdown and puts focus on first item`, async () => {
it(`Space opens dropdown and puts focus on first item and subsequent Space do not change the focus`, async () => {
const inputEl = await page.find(`#myCombobox >>> input`);
await inputEl.focus();
await page.waitForChanges();
Expand All @@ -910,6 +910,12 @@ describe("calcite-combobox", () => {

const visible = await firstFocusedGroupItem.isVisible();
expect(visible).toBe(true);

await page.keyboard.press("Space");
await page.waitForChanges();
await page.keyboard.press("Space");
await page.waitForChanges();
expect(firstFocusedGroupItem).toBeTruthy();
});

it("when the combobox is focused & closed, Page up/down (fn arrow up/down) scrolls up and down the page", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,11 @@ export class Combobox
break;
case " ":
if (!this.textInput.value) {
if (!this.open) {
this.open = true;
this.shiftActiveItemIndex(1);
}
event.preventDefault();
this.open = true;
this.shiftActiveItemIndex(1);
}
break;
case "Home":
Expand Down

0 comments on commit 58e2ff2

Please sign in to comment.