From ab6cdff97e710da47b113642f9bcb735a515375e Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 10 Apr 2023 15:38:46 -0400 Subject: [PATCH] fix(menu): refs are not destroyed on unmount (#27158) --- core/src/components/menu/menu.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/components/menu/menu.tsx b/core/src/components/menu/menu.tsx index b243b8ad98..42dbee8cbf 100644 --- a/core/src/components/menu/menu.tsx +++ b/core/src/components/menu/menu.tsx @@ -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) { @@ -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' })