Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): menu button is enabled with Angular Universal builds #27814

Merged
merged 9 commits into from
Jul 18, 2023
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