diff --git a/core/src/components/menu/menu.tsx b/core/src/components/menu/menu.tsx index ff0dd4e2023..f89a0cede9c 100644 --- a/core/src/components/menu/menu.tsx +++ b/core/src/components/menu/menu.tsx @@ -241,7 +241,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) { @@ -253,7 +262,7 @@ export class Menu implements ComponentInterface, MenuI { } this.animation = undefined; - this.contentEl = this.backdropEl = this.menuInnerEl = undefined; + this.contentEl = undefined; } @Listen('ionSplitPaneVisible', { target: 'body' })