Skip to content

Commit

Permalink
feat(action-group): Adds overlayPositioning property. (#7366)
Browse files Browse the repository at this point in the history
**Related Issue:** N/A

## Summary

- Adds overlayPositioning property
- Allows a user to set the `overlayPositioning` on the internal
`calcite-action-menu`
  • Loading branch information
driskull committed Jul 24, 2023
1 parent cc592e6 commit ca9f35a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
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
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

0 comments on commit ca9f35a

Please sign in to comment.