diff --git a/packages/calcite-components/src/components/action-bar/action-bar.e2e.ts b/packages/calcite-components/src/components/action-bar/action-bar.e2e.ts index d1948791607..f4a0bbfe9ef 100755 --- a/packages/calcite-components/src/components/action-bar/action-bar.e2e.ts +++ b/packages/calcite-components/src/components/action-bar/action-bar.e2e.ts @@ -3,6 +3,7 @@ import { html } from "../../../support/formatting"; import { accessible, defaults, focusable, hidden, reflects, renders, slots, t9n } from "../../tests/commonTests"; import { CSS, SLOTS } from "./resources"; import { overflowActionsDebounceInMs } from "./utils"; +import { getFocusedElementProp } from "../../tests/utils"; describe("calcite-action-bar", () => { describe("renders", () => { @@ -247,6 +248,21 @@ describe("calcite-action-bar", () => { focusTargetSelector: "calcite-action" } ); + + it("should not focus any action element when clicked on non-focusable region", async () => { + const page = await newE2EPage(); + await page.setContent(html` + `); + + const actionBarElRect = await page.evaluate(() => { + const actionBarEl = document.querySelector("calcite-action-bar"); + return actionBarEl.getBoundingClientRect().toJSON(); + }); + + await page.mouse.click(actionBarElRect.right / 2, actionBarElRect.y + actionBarElRect.bottom / 2); + expect(await getFocusedElementProp(page, "tagName", { shadow: true })).not.toBe("CALCITE-ACTION"); + }); }); describe("slots", () => { diff --git a/packages/calcite-components/src/components/action-bar/action-bar.scss b/packages/calcite-components/src/components/action-bar/action-bar.scss index ac76c819ea1..e23aaa874ee 100755 --- a/packages/calcite-components/src/components/action-bar/action-bar.scss +++ b/packages/calcite-components/src/components/action-bar/action-bar.scss @@ -16,10 +16,16 @@ :host([layout="vertical"]) { @apply flex-col; + .action-group--bottom { + margin-block-start: auto; + } } :host([layout="horizontal"]) { @apply flex-row; + .action-group--bottom { + @apply ms-auto; + } } :host([layout="vertical"][overflow-actions-disabled]) { @@ -53,5 +59,5 @@ } .action-group--bottom { - @apply flex-grow justify-end; + @apply justify-end; } diff --git a/packages/calcite-components/src/components/action-bar/action-bar.tsx b/packages/calcite-components/src/components/action-bar/action-bar.tsx index 7909fcba661..04df478a53c 100755 --- a/packages/calcite-components/src/components/action-bar/action-bar.tsx +++ b/packages/calcite-components/src/components/action-bar/action-bar.tsx @@ -17,7 +17,7 @@ import { connectConditionalSlotComponent, disconnectConditionalSlotComponent } from "../../utils/conditionalSlot"; -import { getSlotted, slotChangeGetAssignedElements } from "../../utils/dom"; +import { focusFirstTabbable, getSlotted, slotChangeGetAssignedElements } from "../../utils/dom"; import { componentFocusable, LoadableComponent, @@ -53,14 +53,20 @@ import { @Component({ tag: "calcite-action-bar", styleUrl: "action-bar.scss", - shadow: { - delegatesFocus: true - }, + shadow: true, assetsDirs: ["assets"] }) export class ActionBar implements ConditionalSlotComponent, LoadableComponent, LocalizedComponent, T9nComponent { + //-------------------------------------------------------------------------- + // + // Element + // + //-------------------------------------------------------------------------- + + @Element() el: HTMLCalciteActionBarElement; + // -------------------------------------------------------------------------- // // Properties @@ -157,8 +163,6 @@ export class ActionBar // // -------------------------------------------------------------------------- - @Element() el: HTMLCalciteActionBarElement; - mutationObserver = createObserver("mutation", () => { const { el, expanded } = this; toggleChildActionText({ el, expanded }); @@ -245,7 +249,7 @@ export class ActionBar async setFocus(): Promise { await componentFocusable(this); - this.el?.focus(); + focusFirstTabbable(this.el); } // --------------------------------------------------------------------------