Skip to content
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

feat(action-group): Adds overlayPositioning property. #7366

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -14,6 +14,10 @@ describe("calcite-action-group", () => {
propertyName: "layout",
defaultValue: "vertical",
},
{
propertyName: "overlayPositioning",
defaultValue: "absolute",
},
]);
});

Expand Down Expand Up @@ -43,6 +47,17 @@ describe("calcite-action-group", () => {
expect(await menu.getProperty("scale")).toBe("l");
});

it("should honor overlayPositioning", async () => {
const page = await newE2EPage();
await page.setContent(`<calcite-action-group scale="l" overlay-positioning="fixed">
<calcite-action id="plus" slot="menu-actions" text="Add" icon="plus"></calcite-action>
<calcite-action id="banana" slot="menu-actions" text="Banana" icon="banana"></calcite-action>
</calcite-action-group>`);
await page.waitForChanges();
const menu = await page.find(`calcite-action-group >>> calcite-action-menu`);
expect(await menu.getProperty("overlayPositioning")).toBe("fixed");
});

describe("translation support", () => {
t9n("calcite-action-group");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { SLOTS as ACTION_MENU_SLOTS } from "../action-menu/resources";
import { Columns, Layout, Scale } from "../interfaces";
import { ActionGroupMessages } from "./assets/action-group/t9n";
import { ICONS, SLOTS } from "./resources";
import { OverlayPositioning } from "../../utils/floating-ui";

/**
* @slot - A slot for adding a group of `calcite-action`s.
Expand Down Expand Up @@ -74,6 +75,15 @@ export class ActionGroup
*/
@Prop({ reflect: true, mutable: true }) menuOpen = false;

/**
* Determines the type of positioning to use for the overlaid content.
*
* Using `"absolute"` will work for most cases. The component will be positioned inside of overflowing parent containers and will affect the container's layout.
* `"fixed"` should be used to escape an overflowing parent container, or when the reference element's `position` CSS property is `"fixed"`.
*
*/
@Prop({ reflect: true }) overlayPositioning: OverlayPositioning = "absolute";

/**
* Specifies the size of the `calcite-action-menu`.
*/
Expand Down Expand Up @@ -167,7 +177,7 @@ export class ActionGroup
}

renderMenu(): VNode {
const { el, expanded, menuOpen, scale, layout, messages } = this;
const { el, expanded, menuOpen, scale, layout, messages, overlayPositioning } = this;

const hasMenuItems = getSlotted(el, SLOTS.menuActions);

Expand All @@ -178,6 +188,7 @@ export class ActionGroup
label={messages.more}
onCalciteActionMenuOpen={this.setMenuOpen}
open={menuOpen}
overlayPositioning={overlayPositioning}
placement={layout === "horizontal" ? "bottom-start" : "leading-start"}
scale={scale}
>
Expand Down