Skip to content

Commit

Permalink
fix(action-menu): keep internal popover open property in sync (#8387)
Browse files Browse the repository at this point in the history
**Related Issue:** #7445

## Summary

- Keep open property in sync with open property of internal popover
- Update menu button element when connectedCallback occurs.
- Add test
  • Loading branch information
driskull authored Dec 9, 2023
1 parent bfdf5c5 commit 38dff7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ describe("calcite-action-menu", () => {

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

expect(await popover.getProperty("open")).toBe(true);

expect(await actionMenu.getProperty("open")).toBe(true);

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

expect(await actionMenu.getProperty("open")).toBe(false);

expect(await popover.getProperty("open")).toBe(false);
});

it("should close menu if slotted action is clicked", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export class ActionMenu implements LoadableComponent {
//
// --------------------------------------------------------------------------

connectedCallback(): void {
this.connectMenuButtonEl();
}

componentWillLoad(): void {
setUpLoadableComponent(this);
}
Expand Down Expand Up @@ -294,6 +298,7 @@ export class ActionMenu implements LoadableComponent {
label={label}
offsetDistance={0}
onCalcitePopoverClose={this.handlePopoverClose}
onCalcitePopoverOpen={this.handlePopoverOpen}
open={open}
overlayPositioning={overlayPositioning}
placement={placement}
Expand Down Expand Up @@ -500,6 +505,10 @@ export class ActionMenu implements LoadableComponent {
this.open = value;
};

private handlePopoverOpen = (): void => {
this.open = true;
};

private handlePopoverClose = (): void => {
this.open = false;
};
Expand Down

0 comments on commit 38dff7c

Please sign in to comment.