Skip to content

Commit ca9f35a

Browse files
authored
feat(action-group): Adds overlayPositioning property. (#7366)
**Related Issue:** N/A ## Summary - Adds overlayPositioning property - Allows a user to set the `overlayPositioning` on the internal `calcite-action-menu`
1 parent cc592e6 commit ca9f35a

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/calcite-components/src/components/action-group/action-group.e2e.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ describe("calcite-action-group", () => {
1414
propertyName: "layout",
1515
defaultValue: "vertical",
1616
},
17+
{
18+
propertyName: "overlayPositioning",
19+
defaultValue: "absolute",
20+
},
1721
]);
1822
});
1923

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

50+
it("should honor overlayPositioning", async () => {
51+
const page = await newE2EPage();
52+
await page.setContent(`<calcite-action-group scale="l" overlay-positioning="fixed">
53+
<calcite-action id="plus" slot="menu-actions" text="Add" icon="plus"></calcite-action>
54+
<calcite-action id="banana" slot="menu-actions" text="Banana" icon="banana"></calcite-action>
55+
</calcite-action-group>`);
56+
await page.waitForChanges();
57+
const menu = await page.find(`calcite-action-group >>> calcite-action-menu`);
58+
expect(await menu.getProperty("overlayPositioning")).toBe("fixed");
59+
});
60+
4661
describe("translation support", () => {
4762
t9n("calcite-action-group");
4863
});

packages/calcite-components/src/components/action-group/action-group.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { SLOTS as ACTION_MENU_SLOTS } from "../action-menu/resources";
2424
import { Columns, Layout, Scale } from "../interfaces";
2525
import { ActionGroupMessages } from "./assets/action-group/t9n";
2626
import { ICONS, SLOTS } from "./resources";
27+
import { OverlayPositioning } from "../../utils/floating-ui";
2728

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

78+
/**
79+
* Determines the type of positioning to use for the overlaid content.
80+
*
81+
* Using `"absolute"` will work for most cases. The component will be positioned inside of overflowing parent containers and will affect the container's layout.
82+
* `"fixed"` should be used to escape an overflowing parent container, or when the reference element's `position` CSS property is `"fixed"`.
83+
*
84+
*/
85+
@Prop({ reflect: true }) overlayPositioning: OverlayPositioning = "absolute";
86+
7787
/**
7888
* Specifies the size of the `calcite-action-menu`.
7989
*/
@@ -167,7 +177,7 @@ export class ActionGroup
167177
}
168178

169179
renderMenu(): VNode {
170-
const { el, expanded, menuOpen, scale, layout, messages } = this;
180+
const { el, expanded, menuOpen, scale, layout, messages, overlayPositioning } = this;
171181

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

@@ -178,6 +188,7 @@ export class ActionGroup
178188
label={messages.more}
179189
onCalciteActionMenuOpen={this.setMenuOpen}
180190
open={menuOpen}
191+
overlayPositioning={overlayPositioning}
181192
placement={layout === "horizontal" ? "bottom-start" : "leading-start"}
182193
scale={scale}
183194
>

0 commit comments

Comments
 (0)