Skip to content

Commit b53b66a

Browse files
crisbetojosephperrott
authored andcommitted
fix(menu): changed after checked error when toggling quickly between triggers for same submenu (#12209)
1 parent 7301fa0 commit b53b66a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/menu/menu-trigger.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,10 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
501501
// while the new trigger tries to re-open it. Wait for the animation to finish
502502
// before doing so. Also interrupt if the user moves to another item.
503503
if (this.menu instanceof MatMenu && this.menu._isAnimating) {
504+
// We need the `delay(0)` here in order to avoid
505+
// 'changed after checked' errors in some cases. See #12194.
504506
this.menu._animationDone
505-
.pipe(take(1), takeUntil(this._parentMenu._hovered()))
507+
.pipe(take(1), delay(0, asapScheduler), takeUntil(this._parentMenu._hovered()))
506508
.subscribe(() => this.openMenu());
507509
} else {
508510
this.openMenu();

0 commit comments

Comments
 (0)