Skip to content

Commit 38dff7c

Browse files
authored
fix(action-menu): keep internal popover open property in sync (#8387)
**Related Issue:** #7445 ## Summary - Keep open property in sync with open property of internal popover - Update menu button element when connectedCallback occurs. - Add test
1 parent bfdf5c5 commit 38dff7c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ describe("calcite-action-menu", () => {
139139

140140
expect(await popover.getProperty("autoClose")).toBe(true);
141141

142+
expect(await popover.getProperty("open")).toBe(true);
143+
142144
expect(await actionMenu.getProperty("open")).toBe(true);
143145

144146
const outside = await page.find("#outside");
@@ -148,6 +150,8 @@ describe("calcite-action-menu", () => {
148150
await page.waitForChanges();
149151

150152
expect(await actionMenu.getProperty("open")).toBe(false);
153+
154+
expect(await popover.getProperty("open")).toBe(false);
151155
});
152156

153157
it("should close menu if slotted action is clicked", async () => {

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

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export class ActionMenu implements LoadableComponent {
4343
//
4444
// --------------------------------------------------------------------------
4545

46+
connectedCallback(): void {
47+
this.connectMenuButtonEl();
48+
}
49+
4650
componentWillLoad(): void {
4751
setUpLoadableComponent(this);
4852
}
@@ -294,6 +298,7 @@ export class ActionMenu implements LoadableComponent {
294298
label={label}
295299
offsetDistance={0}
296300
onCalcitePopoverClose={this.handlePopoverClose}
301+
onCalcitePopoverOpen={this.handlePopoverOpen}
297302
open={open}
298303
overlayPositioning={overlayPositioning}
299304
placement={placement}
@@ -500,6 +505,10 @@ export class ActionMenu implements LoadableComponent {
500505
this.open = value;
501506
};
502507

508+
private handlePopoverOpen = (): void => {
509+
this.open = true;
510+
};
511+
503512
private handlePopoverClose = (): void => {
504513
this.open = false;
505514
};

0 commit comments

Comments
 (0)