Skip to content

Commit c1364ab

Browse files
crisbetoAbderrahmane Hamila
authored and
Abderrahmane Hamila
committed
fix(menu): not unsubscribing from close stream if trigger is destroyed (#14107)
Fixes the menu trigger not unsubscribing from the menu panel's `close` stream. In most cases it isn't an issue, because `close` gets completed when the panel is destroyed, however the user can still run into it if the trigger is destroyed, but the panel stays in place.
1 parent c08ae99 commit c1364ab

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib/menu/menu-trigger.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
8585
private _portal: TemplatePortal;
8686
private _overlayRef: OverlayRef | null = null;
8787
private _menuOpen: boolean = false;
88-
private _closeSubscription = Subscription.EMPTY;
88+
private _closingActionsSubscription = Subscription.EMPTY;
8989
private _hoverSubscription = Subscription.EMPTY;
9090
private _menuCloseSubscription = Subscription.EMPTY;
9191
private _scrollStrategy: () => ScrollStrategy;
@@ -195,6 +195,7 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
195195
passiveEventListenerOptions);
196196

197197
this._cleanUpSubscriptions();
198+
this._closingActionsSubscription.unsubscribe();
198199
}
199200

200201
/** Whether the menu is open. */
@@ -237,7 +238,7 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
237238
this.menu.lazyContent.attach(this.menuData);
238239
}
239240

240-
this._closeSubscription = this._menuClosingActions().subscribe(() => this.closeMenu());
241+
this._closingActionsSubscription = this._menuClosingActions().subscribe(() => this.closeMenu());
241242
this._initMenu();
242243

243244
if (this.menu instanceof MatMenu) {
@@ -270,7 +271,7 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
270271

271272
const menu = this.menu;
272273

273-
this._closeSubscription.unsubscribe();
274+
this._closingActionsSubscription.unsubscribe();
274275
this._overlayRef.detach();
275276

276277
if (menu instanceof MatMenu) {
@@ -469,7 +470,7 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
469470

470471
/** Cleans up the active subscriptions. */
471472
private _cleanUpSubscriptions(): void {
472-
this._closeSubscription.unsubscribe();
473+
this._closingActionsSubscription.unsubscribe();
473474
this._hoverSubscription.unsubscribe();
474475
}
475476

0 commit comments

Comments
 (0)