Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/material/menu/menu-trigger-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,14 @@ export abstract class MatMenuTriggerBase implements OnDestroy {
if (menu instanceof MatMenu && this._ownsMenu(menu)) {
this._pendingRemoval = menu._animationDone.pipe(take(1)).subscribe(() => {
overlayRef.detach();
menu.lazyContent?.detach();

// Only detach the lazy content if no other trigger took over the menu, otherwise we may
// detach something we no longer own. Note that we don't use `this._ownsMenu` here,
// because the current trigger relinquishes ownership as soon as the closing sequence
// is kicked off whereas the animation takes some time to play out.
if (!PANELS_TO_TRIGGERS.has(menu)) {
menu.lazyContent?.detach();
}
});
menu._setIsOpen(false);
} else {
Expand Down
Loading