bug(menu): Using menu in component with CD "OnPush" and *ngIf causing "ExpressionChangedAfterItHasBeenCheckedError"
See original GitHub issueIs 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:
- Create a component which uses
matMenuTriggerFor
directive. Let’s call itcmp1
. - Create component
cmp2
with change detectionOnPush
- Inside
cmp2
template create html element with*ngIf
directive (<div *ngIf="foo"></div>
) - 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
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:
- Created a year ago
- Comments:7 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did reproduce it with your zip file, but I haven’t had the time to narrow down the root cause.
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.