diff --git a/projects/igniteui-angular/src/lib/grids/grid-base.component.ts b/projects/igniteui-angular/src/lib/grids/grid-base.component.ts index 74fa509ebb0..1b9ccaa6a87 100644 --- a/projects/igniteui-angular/src/lib/grids/grid-base.component.ts +++ b/projects/igniteui-angular/src/lib/grids/grid-base.component.ts @@ -2288,6 +2288,12 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements this.summaryService.clearSummaryCache(); this._pipeTrigger++; this.markForCheck(); + if (this.transactions.getAggregatedChanges(false).length === 0) { + // Needs better check, calling 'transactions.clear()' will also trigger this + if (this.data.length % this.perPage === 0 && this.isLastPage && this.page !== 0) { + this.page--; + } + } }); } @@ -3072,13 +3078,22 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements this.checkHeaderCheckboxStatus(); } + const addedRowsDif = this.dataWithAddedInTransactionRows.length - this.data.length; this.deleteRowFromData(rowId, index); this._pipeTrigger++; this.cdr.markForCheck(); this.refreshSearch(); - if (data.length % this.perPage === 0 && this.isLastPage && this.page !== 0) { - this.page--; + if (this.isLastPage && this.page !== 0) { + let pageSwitch = 0; + if (!this.transactions.enabled) { + pageSwitch = this.data.length % this.perPage === 0 ? 1 : 0; + } else { + if (addedRowsDif) { + pageSwitch = this.dataWithAddedInTransactionRows.length % this.perPage === 0 ? 1 : 0; + } + } + this.page -= pageSwitch; } }