diff --git a/core/src/components/menu/menu.tsx b/core/src/components/menu/menu.tsx index 56c6e3a919..c010e72d2d 100644 --- a/core/src/components/menu/menu.tsx +++ b/core/src/components/menu/menu.tsx @@ -1,6 +1,7 @@ import type { ComponentInterface, EventEmitter } from '@stencil/core'; import { Build, Component, Element, Event, Host, Listen, Method, Prop, State, Watch, h } from '@stencil/core'; import { getTimeGivenProgression } from '@utils/animation/cubic-bezier'; +import { doc } from '@utils/browser'; import { GESTURE_CONTROLLER } from '@utils/gesture'; import type { Attributes } from '@utils/helpers'; import { inheritAriaAttributes, assert, clamp, isEndSide as isEnd } from '@utils/helpers'; @@ -189,7 +190,6 @@ export class Menu implements ComponentInterface, MenuI { } if (!Build.isBrowser) { - this.disabled = true; return; } @@ -705,9 +705,18 @@ export class Menu implements ComponentInterface, MenuI { this.forceClosing(); } - if (!this.disabled) { - menuController._setActiveMenu(this); + if (doc?.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. + */ + if (!this.disabled) { + menuController._setActiveMenu(this); + } } + assert(!this.isAnimating, 'can not be animating'); }