Skip to content

Commit a5fbf3a

Browse files
authored
fix(multiple): some experimental components not cleaned up completely (#23994)
Fixes a few cases where we weren't destroying the MDC foundation in our own components. There's also a case where we were overriding the `ngOnDestroy` from a parent component, but we weren't calling it from the override.
1 parent 603b248 commit a5fbf3a

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

src/cdk-experimental/menu/menu.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ export class CdkMenu extends CdkMenuGroup implements Menu, AfterContentInit, OnI
340340
}
341341

342342
override ngOnDestroy() {
343+
super.ngOnDestroy();
343344
this._emitClosedEvent();
344345
this._pointerTracker?.destroy();
345346
}

src/material-experimental/mdc-form-field/form-field.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ export class MatFormField
408408
}
409409

410410
ngOnDestroy() {
411+
this._foundation?.destroy();
411412
this._destroyed.next();
412413
this._destroyed.complete();
413414
}

src/material-experimental/mdc-list/list-option.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ export class MatListOption extends MatListItemBase implements ListOption, OnInit
201201
}
202202

203203
override ngOnDestroy(): void {
204+
super.ngOnDestroy();
205+
204206
if (this.selected) {
205207
// We have to delay this until the next tick in order
206208
// to avoid changed after checked errors.

src/material-experimental/mdc-list/selection-list.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export class MatSelectionList
183183
}
184184

185185
override ngOnDestroy() {
186+
super.ngOnDestroy();
186187
this._destroyed.next();
187188
this._destroyed.complete();
188189
this._isDestroyed = true;

0 commit comments

Comments
 (0)