question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(menu): Using menu in component with CD "OnPush" and *ngIf causing "ExpressionChangedAfterItHasBeenCheckedError"

See original GitHub issue

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

13.2.2

Description

Following error is thrown after opening the menu:

Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value for '@transformMenu': 'void'. Current value: 'enter'.. 

Reproduction

Steps to reproduce:

  1. Create a component which uses matMenuTriggerFor directive. Let’s call it cmp1.
  2. Create component cmp2 with change detection OnPush
  3. Inside cmp2 template create html element with *ngIf directive (<div *ngIf="foo"></div>)
  4. Place cmp1 element inside the element with *ngIf

Expected Behavior

No errors when opening the menu.

Actual Behavior

Error:

NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value for '@transformMenu': 'void'. Current value: 'enter'..

Reproduction demo app

mat-menu-bug.zip

Environment

  • Angular: 13.2.3
  • CDK/Material: 13.2.3
  • Browser(s): Chrome 100
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
crisbetocommented, Apr 19, 2022

I did reproduce it with your zip file, but I haven’t had the time to narrow down the root cause.

0reactions
angular-automatic-lock-bot[bot]commented, Oct 2, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ngIf - Expression has changed after it was checked
The problem is that because the text changes when it is fetched, the 'expand' button's condition turns to true after Angular's change detection ......
Read more >
Angular Debugging "Expression has changed": Explanation ...
Learn a complete explanation about ExpressionChangedAfterItHasBeenCheckedError: why it occurs, how to troubleshoot it and how to fix it.
Read more >
ExpressionChangedAfterItHasBe...
The expression has changed after it was checked (Expressionchangedafterithasbeencheckederror) is one of the common errors, that we encounter ...
Read more >
angular/angular - Gitter
just want to have some *ngIf's in my main index.html that affect the overall layout depending on the route. or is that bad...
Read more >
primeng/CHANGELOG.md - UNPKG
378, - Reimplement Popup Mode of Menu, TieredMenu and SlideMenu ... 578, - PrimeNg Growl component causes Protractor synchronisation with Angular failure ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found