@acorex/components 21.0.1-next.46 → 21.0.1-next.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1641,6 +1641,19 @@ class AXDataTableComponent extends AXBaseDataTable {
1641
1641
  this.displayedRows.set(data.items.filter((item) => !item[this.parentField]));
1642
1642
  this.totalRows = data.totalCount;
1643
1643
  this.hasItems = data.totalCount > 0;
1644
+ // When current page is beyond max valid page (e.g. after deleting last item on last page), navigate to previous page
1645
+ if (this.paging && data.totalCount > 0) {
1646
+ const pageSize = this.dataSource.pageSize;
1647
+ const maxPageIndex = Math.ceil(data.totalCount / pageSize) - 1;
1648
+ const currentPageIndex = this.page();
1649
+ if (currentPageIndex > maxPageIndex) {
1650
+ const newPageIndex = Math.max(0, maxPageIndex);
1651
+ this.page.set(newPageIndex);
1652
+ this.dataSource.setPage(newPageIndex);
1653
+ const pager = this.dataPager ?? this.customDataPager;
1654
+ pager?.goToPage(newPageIndex + 1);
1655
+ }
1656
+ }
1644
1657
  });
1645
1658
  this.dataSource.onItemExpanded.pipe(this._unsubscriber.takeUntilDestroy).subscribe((data) => {
1646
1659
  const { expandedItem, children } = data;