Skip to content
15 changes: 12 additions & 3 deletions core/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -189,7 +190,6 @@ export class Menu implements ComponentInterface, MenuI {
}

if (!Build.isBrowser) {
this.disabled = true;
return;
}

Expand Down Expand Up @@ -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');
}

Expand Down