Skip to content

Commit 39c0074

Browse files
crisbetommalerba
authored andcommitted
fix(sidenav): not destroying custom QueryList (#17619)
We maintain a custom `QuestList` called `_drawers` which contains only the drawers that belong to the particular container, however we never destroy it.
1 parent 1923f7f commit 39c0074

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/material/sidenav/drawer.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,20 @@ describe('MatDrawerContainer', () => {
848848
.toBe(true);
849849
}));
850850

851+
it('should clean up the drawers stream on destroy', fakeAsync(() => {
852+
const fixture = TestBed.createComponent(DrawerContainerTwoDrawerTestApp);
853+
fixture.detectChanges();
854+
855+
const spy = jasmine.createSpy('complete spy');
856+
const subscription = fixture.componentInstance.drawerContainer._drawers.changes.subscribe({
857+
complete: spy
858+
});
851859

860+
fixture.destroy();
861+
862+
expect(spy).toHaveBeenCalled();
863+
subscription.unsubscribe();
864+
}));
852865
});
853866

854867

src/material/sidenav/drawer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy
630630
ngOnDestroy() {
631631
this._contentMarginChanges.complete();
632632
this._doCheckSubject.complete();
633+
this._drawers.destroy();
633634
this._destroyed.next();
634635
this._destroyed.complete();
635636
}

0 commit comments

Comments
 (0)