From 96b27074616daf4a2c7cd318ab13324463d200b8 Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Wed, 12 Jul 2023 23:38:55 -0400 Subject: [PATCH 1/9] fix(menu): menu is enabled in ssr hydration --- core/src/components/menu/menu.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/core/src/components/menu/menu.tsx b/core/src/components/menu/menu.tsx index 56c6e3a919f..3e6d1b6dc20 100644 --- a/core/src/components/menu/menu.tsx +++ b/core/src/components/menu/menu.tsx @@ -188,11 +188,6 @@ export class Menu implements ComponentInterface, MenuI { this.type = config.get('menuType', 'overlay'); } - if (!Build.isBrowser) { - this.disabled = true; - return; - } - const content = this.contentId !== undefined ? document.getElementById(this.contentId) : null; if (content === null) { From a8e86a7699adcc2812fcf00420abd0a4804b7d1a Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Wed, 12 Jul 2023 23:41:35 -0400 Subject: [PATCH 2/9] chore: smoke test --- core/src/components/menu/menu.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/components/menu/menu.tsx b/core/src/components/menu/menu.tsx index 3e6d1b6dc20..6f4308b4220 100644 --- a/core/src/components/menu/menu.tsx +++ b/core/src/components/menu/menu.tsx @@ -188,6 +188,11 @@ export class Menu implements ComponentInterface, MenuI { this.type = config.get('menuType', 'overlay'); } + if (!Build.isBrowser) { + // this.disabled = true; + return; + } + const content = this.contentId !== undefined ? document.getElementById(this.contentId) : null; if (content === null) { From 6b79224efb40b8936e61361fa6250d1df794e6e1 Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Thu, 13 Jul 2023 00:10:25 -0400 Subject: [PATCH 3/9] chore: prevent disabling menu during ssr --- core/src/components/menu/menu.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/components/menu/menu.tsx b/core/src/components/menu/menu.tsx index 6f4308b4220..c1726550f7f 100644 --- a/core/src/components/menu/menu.tsx +++ b/core/src/components/menu/menu.tsx @@ -705,8 +705,10 @@ export class Menu implements ComponentInterface, MenuI { this.forceClosing(); } - if (!this.disabled) { - menuController._setActiveMenu(this); + if (!Build.isServer) { + if (!this.disabled) { + menuController._setActiveMenu(this); + } } assert(!this.isAnimating, 'can not be animating'); } From 4fb5a2657c729e757a9bcf018fcfd849bae9955f Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Mon, 17 Jul 2023 14:26:44 -0400 Subject: [PATCH 4/9] fix: prevent setting active menu to removed menu node --- core/src/components/menu/menu.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/src/components/menu/menu.tsx b/core/src/components/menu/menu.tsx index c1726550f7f..1703dda0f05 100644 --- a/core/src/components/menu/menu.tsx +++ b/core/src/components/menu/menu.tsx @@ -705,11 +705,16 @@ export class Menu implements ComponentInterface, MenuI { this.forceClosing(); } - if (!Build.isServer) { - if (!this.disabled) { - menuController._setActiveMenu(this); - } + if (document.contains(this.el)) { + /** + * Only set the active menu if the menu element is + * present in the DOM. Otherwise if it was destructively + * re-hydrated (through Angular Universal), then ignore + * setting the removed node as the active menu. + */ + menuController._setActiveMenu(this); } + assert(!this.isAnimating, 'can not be animating'); } From 6959f93933bfe9d29e8dce504949d507691d3b93 Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Mon, 17 Jul 2023 15:27:44 -0400 Subject: [PATCH 5/9] chore: clean-up --- core/src/components/menu/menu.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/components/menu/menu.tsx b/core/src/components/menu/menu.tsx index 1703dda0f05..21934dcc1a9 100644 --- a/core/src/components/menu/menu.tsx +++ b/core/src/components/menu/menu.tsx @@ -189,7 +189,6 @@ export class Menu implements ComponentInterface, MenuI { } if (!Build.isBrowser) { - // this.disabled = true; return; } From c653065cb0de29eea835cdefdefa5f1827f32e5c Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Mon, 17 Jul 2023 15:50:23 -0400 Subject: [PATCH 6/9] test: allow activating different menu from same side --- core/src/components/menu/test/basic/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/components/menu/test/basic/index.html b/core/src/components/menu/test/basic/index.html index af0074a4cbd..49efc273127 100644 --- a/core/src/components/menu/test/basic/index.html +++ b/core/src/components/menu/test/basic/index.html @@ -129,6 +129,7 @@