Skip to content

Commit

Permalink
fix(multiple): some experimental components not cleaned up completely (
Browse files Browse the repository at this point in the history
…#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.

(cherry picked from commit a5fbf3a)
  • Loading branch information
crisbeto authored and zarend committed Nov 23, 2021
1 parent 3804801 commit f05a9c6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cdk-experimental/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ export class CdkMenu extends CdkMenuGroup implements Menu, AfterContentInit, OnI
}

override ngOnDestroy() {
super.ngOnDestroy();
this._emitClosedEvent();
this._pointerTracker?.destroy();
}
Expand Down
1 change: 1 addition & 0 deletions src/material-experimental/mdc-form-field/form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ export class MatFormField
}

ngOnDestroy() {
this._foundation?.destroy();
this._destroyed.next();
this._destroyed.complete();
}
Expand Down
2 changes: 2 additions & 0 deletions src/material-experimental/mdc-list/list-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ export class MatListOption extends MatListItemBase implements ListOption, OnInit
}

override ngOnDestroy(): void {
super.ngOnDestroy();

if (this.selected) {
// We have to delay this until the next tick in order
// to avoid changed after checked errors.
Expand Down
1 change: 1 addition & 0 deletions src/material-experimental/mdc-list/selection-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export class MatSelectionList
}

override ngOnDestroy() {
super.ngOnDestroy();
this._destroyed.next();
this._destroyed.complete();
this._isDestroyed = true;
Expand Down

0 comments on commit f05a9c6

Please sign in to comment.