Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
fix(table): Fixes an issue where the expandable row did not clean up …
Browse files Browse the repository at this point in the history
…after itself.

Fixes APM-292781
  • Loading branch information
tomheller committed Mar 26, 2021
1 parent 8f380bd commit 80c6477
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions libs/barista-components/table/src/expandable/expandable-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ export class DtExpandableRow
// tslint:disable-next-line: no-any
_expandableContentTemplate: TemplateRef<any> | null;

private _selectionDispatchCleanup: () => void;

constructor(
// tslint:disable-next-line:no-any
private _table: DtTable<any>,
Expand All @@ -175,20 +177,22 @@ export class DtExpandableRow
) {
super(elementRef);
this._table._hasExpandableRows = true;
this._expansionDispatcher.listen((rowId, tableId) => {
/**
* If the table does not allow multiple rows to be expanded at a time,
* the currently expanded row is collapsed.
*/
if (
this._table &&
!this._table.multiExpand &&
this._table._uniqueId === tableId &&
this._uniqueId !== rowId
) {
this._collapse();
}
});
this._selectionDispatchCleanup = this._expansionDispatcher.listen(
(rowId, tableId) => {
/**
* If the table does not allow multiple rows to be expanded at a time,
* the currently expanded row is collapsed.
*/
if (
this._table &&
!this._table.multiExpand &&
this._table._uniqueId === tableId &&
this._uniqueId !== rowId
) {
this._collapse();
}
},
);

this._collapseAnimation = _animationBuilder.build(COLLAPSE_ANIMATE);
this._expandAnimation = _animationBuilder.build(EXPAND_ANIMATE);
Expand Down Expand Up @@ -226,6 +230,9 @@ export class DtExpandableRow
ngOnDestroy(): void {
super.ngOnDestroy();
this._templateSubscription.unsubscribe();
if (this._selectionDispatchCleanup) {
this._selectionDispatchCleanup();
}
}

private _expand(): void {
Expand Down

0 comments on commit 80c6477

Please sign in to comment.