Skip to content

bug(MatMenu): Cannot disable animations #21765

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

Closed
MursalovAltun opened this issue Feb 1, 2021 · 11 comments
Closed

bug(MatMenu): Cannot disable animations #21765

MursalovAltun opened this issue Feb 1, 2021 · 11 comments
Assignees
Labels
animation This issue is related to Angular animations or CSS animations area: material/menu P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@MursalovAltun
Copy link

Reproduction

Stackblitz repro

Expected Behavior

Menu animations to be disabled

Actual Behavior

Animations are remain

Environment

  • Angular: 11
  • CDK/Material: 11
  • Browser(s): Google Chrome Version 88.0.4324.96 (Official Build) (64-bit)
  • Operating System (e.g. Windows, macOS, Ubuntu): Xubuntu
@MursalovAltun MursalovAltun added the needs triage This issue needs to be triaged by the team label Feb 1, 2021
@crisbeto
Copy link
Member

crisbeto commented Feb 1, 2021

I suspect that this might be an issue with the @angular/animations module since nothing has fundamentally changed in the menu in a long time.

@crisbeto crisbeto added animation This issue is related to Angular animations or CSS animations area: material/menu P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels Feb 1, 2021
@crisbeto
Copy link
Member

crisbeto commented Feb 1, 2021

I spent a bit of time looking into it, but couldn't find anything specific. One workaround is to define our own Input called @.disabled which then proxies to the inner element, but the problem is that won't pick up any @.disabled bindings on parent elements.

@MursalovAltun
Copy link
Author

I suspect that this might be an issue with the @angular/animations module since nothing has fundamentally changed in the menu in a long time.

I extended the repro stackblitz project with a custom component that have a simple animation which I can disable in parent component using [@.disabled]=true so it seems related more to material components

@crisbeto
Copy link
Member

crisbeto commented Feb 2, 2021

Did this used to work with mat-menu on an earlier version on Material?

@MursalovAltun
Copy link
Author

Did this used to work with mat-menu on an earlier version on Material?

This is not worked on previous versions too
There's a PR which seems like fixes the issue for some components but menu
Also, support for this feature is requested long ago 13017

@MursalovAltun
Copy link
Author

MursalovAltun commented Feb 2, 2021

I'm absolutely sure that this ticket soon will closed due to inactivity. Therefore I'm gonna close this right now to not disturb our lovely bot that closes issues no one cares about :)
So funny that simplest things like overriding animations of a component isn't possible and it takes about 5 years to implement them (see 8857).
Well done!

@crisbeto
Copy link
Member

crisbeto commented Feb 2, 2021

The bot only locks issues that have been closed and haven't had any activity in more than 30 days. For what it's worth, I think that this is a valid issue, but I can't guarantee when it'll be resolved since our team has its own set of commitments.

@crisbeto crisbeto reopened this Feb 2, 2021
@jaykhatri2020
Copy link

To disable the animation in the mat menu, add the following CSS.

.ng-animating, .ng-trigger-transformMenu{
    animation: none !important;
    transition: none !important;
    transform-origin: center center !important;
    animation-duration: 0s !important;
    transform:  none !important;
    opacity: 1 !important;
    pointer-events: all !important;
}

Please note: this will affect all components.

@am-castro
Copy link

Add class on your mat-menu tag, for example:

<mat-menu class="searchMenu" #searchMenu>

And add class on your css file

.searchMenu.ng-animating,
.searchMenu.ng-trigger-transformMenu{
    animation: none !important;
    transition: none !important;
    transform-origin: center center !important;
    animation-duration: 0s !important;
    transform:  none !important;
    opacity: 1 !important;
    pointer-events: all !important;
}

Thanks to @jaykhatri2020 to comment stylesheet

@crisbeto
Copy link
Member

Covered by #20781.

@crisbeto crisbeto self-assigned this Feb 18, 2025
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
animation This issue is related to Angular animations or CSS animations area: material/menu P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

4 participants