Skip to content

Commit

Permalink
fix(menu): refs are not destroyed on unmount (#27158)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamdebeasi authored Apr 10, 2023
1 parent a5f7fe5 commit ab6cdff
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions core/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,16 @@ export class Menu implements ComponentInterface, MenuI {
this.updateState();
}

disconnectedCallback() {
async disconnectedCallback() {
/**
* The menu should be closed when it is
* unmounted from the DOM.
* This is an async call, so we need to wait for
* this to finish otherwise contentEl
* will not have MENU_CONTENT_OPEN removed.
*/
await this.close(false);

this.blocker.destroy();
menuController._unregister(this);
if (this.animation) {
Expand All @@ -246,7 +255,7 @@ export class Menu implements ComponentInterface, MenuI {
}

this.animation = undefined;
this.contentEl = this.backdropEl = this.menuInnerEl = undefined;
this.contentEl = undefined;
}

@Listen('ionSplitPaneVisible', { target: 'body' })
Expand Down

0 comments on commit ab6cdff

Please sign in to comment.