From 92a534bdcfa1659d0d79f564d641504bf8f4dabe Mon Sep 17 00:00:00 2001 From: N1XUS Date: Thu, 7 Dec 2023 16:52:06 +0200 Subject: [PATCH] fix(platform): reset table rows before new rows emitted (#11058) --- .../directives/table-data-source.directive.ts | 1 + libs/platform/table-helpers/table.ts | 2 ++ libs/platform/table/table.component.ts | 20 ++++++++++--------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/libs/platform/table-helpers/directives/table-data-source.directive.ts b/libs/platform/table-helpers/directives/table-data-source.directive.ts index 280381fee82..c6364e9ef19 100644 --- a/libs/platform/table-helpers/directives/table-data-source.directive.ts +++ b/libs/platform/table-helpers/directives/table-data-source.directive.ts @@ -233,5 +233,6 @@ export class TableDataSourceDirective extends DataSourceDirective implements PresetManagedComponent = new EventEmitter(); diff --git a/libs/platform/table/table.component.ts b/libs/platform/table/table.component.ts index 74a9cbc9270..40feb8f65c4 100644 --- a/libs/platform/table/table.component.ts +++ b/libs/platform/table/table.component.ts @@ -1338,6 +1338,17 @@ export class TableComponent 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 */ @@ -1592,15 +1603,6 @@ export class TableComponent /** @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(