Skip to content

Commit

Permalink
Revert "feat(action-menu): Close menu on blur instead of on tab key. (#…
Browse files Browse the repository at this point in the history
…8577)"

This reverts commit ccfbd0c.

# Conflicts:
#	packages/calcite-components/src/components/action-menu/action-menu.e2e.ts
  • Loading branch information
driskull committed Jan 19, 2024
1 parent 0b3b66d commit dd68da0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,13 @@ describe("calcite-action-menu", () => {
expect(await trigger.getProperty("active")).toBe(false);
});

it.skip("should close on blur", async () => {
it.skip("should handle TAB navigation", async () => {
const page = await newE2EPage({
html: html`<calcite-action-menu>
<calcite-action id="first" text="Add" icon="plus" text-enabled></calcite-action>
<calcite-action id="second" text="Add" icon="minus" text-enabled></calcite-action>
<calcite-action id="third" text="Add" icon="banana" text-enabled></calcite-action> </calcite-action-menu
><button>test</button>`,
<calcite-action id="first" text="Add" icon="plus" text-enabled></calcite-action>
<calcite-action id="second" text="Add" icon="minus" text-enabled></calcite-action>
<calcite-action id="third" text="Add" icon="banana" text-enabled></calcite-action>
</calcite-action-menu> `,
});

await page.waitForChanges();
Expand All @@ -429,8 +429,8 @@ describe("calcite-action-menu", () => {
expect(actions[1].getAttribute(activeAttr)).toBe(null);
expect(actions[2].getAttribute(activeAttr)).toBe(null);

const button = await page.find("button");
await button.focus();
await page.keyboard.press("Tab");

await page.waitForChanges();

expect(await actionMenu.getProperty("open")).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ export class ActionMenu implements LoadableComponent {

menuButtonEl.addEventListener("pointerdown", this.menuButtonClick);
menuButtonEl.addEventListener("keydown", this.menuButtonKeyDown);
menuButtonEl.addEventListener("blur", this.menuButtonBlur);
};

disconnectMenuButtonEl = (): void => {
Expand All @@ -236,7 +235,6 @@ export class ActionMenu implements LoadableComponent {

menuButtonEl.removeEventListener("pointerdown", this.menuButtonClick);
menuButtonEl.removeEventListener("keydown", this.menuButtonKeyDown);
menuButtonEl.removeEventListener("blur", this.menuButtonBlur);
};

setMenuButtonEl = (event: Event): void => {
Expand Down Expand Up @@ -419,10 +417,6 @@ export class ActionMenu implements LoadableComponent {
return !!supportedKeys.find((k) => k === key);
}

private menuButtonBlur = (): void => {
this.open = false;
};

menuButtonKeyDown = (event: KeyboardEvent): void => {
const { key } = event;
const { actionElements, activeMenuItemIndex, open } = this;
Expand All @@ -443,6 +437,11 @@ export class ActionMenu implements LoadableComponent {
action ? action.click() : this.toggleOpen(false);
}

if (key === "Tab") {
this.open = false;
return;
}

if (key === "Escape") {
this.toggleOpen(false);
event.preventDefault();
Expand Down

0 comments on commit dd68da0

Please sign in to comment.