diff --git a/libs/barista-components/table/src/cell.ts b/libs/barista-components/table/src/cell.ts index c0d103c9bb..5b9416cd58 100644 --- a/libs/barista-components/table/src/cell.ts +++ b/libs/barista-components/table/src/cell.ts @@ -231,10 +231,18 @@ export class DtCell implements AfterContentInit, OnDestroy { } ngOnDestroy(): void { - this._stateChanges.complete(); - this._sortChangeSubscription.unsubscribe(); - this._destroy.next(); - this._destroy.complete(); + // Exhaustively check if the subjects still exist during the onDestroy + // ADES-5588 + if (this._stateChanges) { + this._stateChanges.complete(); + } + if (this._sortChangeSubscription) { + this._sortChangeSubscription.unsubscribe(); + } + if (this._destroy) { + this._destroy.next(); + this._destroy.complete(); + } if (this._row) { this._row._unregisterCell(this); } diff --git a/libs/barista-components/table/src/header/header-cell.ts b/libs/barista-components/table/src/header/header-cell.ts index 653986e6b2..a90a2d41df 100644 --- a/libs/barista-components/table/src/header/header-cell.ts +++ b/libs/barista-components/table/src/header/header-cell.ts @@ -61,7 +61,11 @@ export class DtHeaderCell implements OnDestroy { } ngOnDestroy(): void { - this._destroy.next(); - this._destroy.complete(); + // Exhaustively check if the subjects still exist during the onDestroy + // ADES-5588 + if (this._destroy) { + this._destroy.next(); + this._destroy.complete(); + } } } diff --git a/libs/barista-components/table/src/order/order-cell.ts b/libs/barista-components/table/src/order/order-cell.ts index efaf3698b5..5461f16918 100644 --- a/libs/barista-components/table/src/order/order-cell.ts +++ b/libs/barista-components/table/src/order/order-cell.ts @@ -122,8 +122,12 @@ export class DtOrderCell } ngOnDestroy(): void { - this._destroy$.next(); - this._destroy$.complete(); + // Exhaustively check if the subjects still exist during the onDestroy + // ADES-5588 + if (this._destroy$) { + this._destroy$.next(); + this._destroy$.complete(); + } } /** diff --git a/libs/barista-components/table/src/selection/selectors.ts b/libs/barista-components/table/src/selection/selectors.ts index 6c33867a7d..8b7cb6697d 100644 --- a/libs/barista-components/table/src/selection/selectors.ts +++ b/libs/barista-components/table/src/selection/selectors.ts @@ -163,8 +163,12 @@ export class DtTableHeaderSelector implements OnDestroy { } ngOnDestroy(): void { - this._destroy$.next(); - this._destroy$.complete(); + // Exhaustively check if the subjects still exist during the onDestroy + // ADES-5588 + if (this._destroy$) { + this._destroy$.next(); + this._destroy$.complete(); + } } /** @internal Callback when the master checkbox is interacted with */ diff --git a/libs/barista-components/table/src/sort/sort.ts b/libs/barista-components/table/src/sort/sort.ts index b56048ef22..a5d130d909 100644 --- a/libs/barista-components/table/src/sort/sort.ts +++ b/libs/barista-components/table/src/sort/sort.ts @@ -103,7 +103,8 @@ export class DtSort /** Event emitted when the user changes either the active sort or sort direction. */ @Output('dtSortChange') - readonly sortChange: EventEmitter = new EventEmitter(); + readonly sortChange: EventEmitter = + new EventEmitter(); /** Sets the active sort id and determines the new sort direction. */ sort(sortable: DtSortHeader): void; @@ -172,8 +173,14 @@ export class DtSort } ngOnDestroy(): void { - this._stateChanges.complete(); - this._initialized.complete(); + // Exhaustively check if the subjects still exist during the onDestroy + // ADES-5588 + if (this._stateChanges) { + this._stateChanges.complete(); + } + if (this._initialized) { + this._initialized.complete(); + } } } diff --git a/libs/barista-components/table/src/table.ts b/libs/barista-components/table/src/table.ts index 53db3233fa..d6e745ffbd 100644 --- a/libs/barista-components/table/src/table.ts +++ b/libs/barista-components/table/src/table.ts @@ -284,9 +284,15 @@ export class DtTable extends _DtTableBase implements OnDestroy { ngOnDestroy(): void { super.ngOnDestroy(); - this._destroy$.next(); - this._destroy$.complete(); - this._portalOutletSubscription.unsubscribe(); + // Exhaustively check if the subjects still exist during the onDestroy + // ADES-5588 + if (this._destroy$) { + this._destroy$.next(); + this._destroy$.complete(); + } + if (this._portalOutletSubscription) { + this._portalOutletSubscription.unsubscribe(); + } } /**