Skip to content

Commit

Permalink
fix(platform): reset table rows before new rows emitted (#11058)
Browse files Browse the repository at this point in the history
  • Loading branch information
N1XUS authored Dec 7, 2023
1 parent a300708 commit 92a534b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,6 @@ export class TableDataSourceDirective<T> extends DataSourceDirective<T, TableDat

this._tableDsSubscription?.unsubscribe();
this._tableDsSubscription = null;
this._table.clearTableRows();
}
}
2 changes: 2 additions & 0 deletions libs/platform/table-helpers/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ export abstract class Table<T = any> implements PresetManagedComponent<PlatformT

abstract refreshDndList(): void;

abstract clearTableRows(): void;

/** Toolbar Sort Settings button click event */
readonly openTableSortSettings: EventEmitter<void> = new EventEmitter<void>();

Expand Down
20 changes: 11 additions & 9 deletions libs/platform/table/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,17 @@ export class TableComponent<T = any>
tableEl.rows[position.rowIndex].cells[position.colIndex].focus();
}

/**
* Clears the array of table rows. Triggered when new data source is applied.
*/
clearTableRows(): void {
this._tableRows = [];
this._tableRowsVisible = [];
this._tableRowsInViewPortPlaceholder = [];
this._newTableRows = [];
this._dataSourceTableRows = [];
}

// Private API

/** @hidden */
Expand Down Expand Up @@ -1592,15 +1603,6 @@ export class TableComponent<T = any>

/** @hidden */
private _listenToTableRowsPipe(): void {
this._subscriptions.add(
/*
* Reset table when the data source is changed,
* because new data source can have different set of data
*/
this._dataSourceDirective.dataSourceChanged.subscribe(() => {
this._setTableRows([]);
})
);
this._subscriptions.add(
this._dataSourceDirective.items$
.pipe(
Expand Down

0 comments on commit 92a534b

Please sign in to comment.