fix(table-core): clamp out-of-range pageIndex when autoResetPageIndex is disabled #6600
Open
cipherprofessor(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/6600/head·opened Showing 14 changed files with 7 additions and 2 deletions (loading 11).
x
@@ -0,0 +1,5 @@
+---
+'@tanstack/table-core': patch
+---
+
+Clamp an out-of-range `pageIndex` to the last page when a data, filter, or grouping change shrinks the rows and `autoResetPageIndex` (or `autoResetAll`) is `false` with client-side pagination, instead of leaving the table on an empty page
@@ -231,7 +231,7 @@
A common reason to set `autoResetPageIndex: false` is editing data while viewing the table (for example, inline cell editing). Every edit updates `data`, which recomputes the row models and would otherwise snap the user back to the first page. Setting the option to a static `false` keeps the current page when the row model recomputes. If you also use the expanding feature, pair it with `autoResetExpanded: false` so expanded rows do not collapse on edits.
-Be aware, however, that if you turn off `autoResetPageIndex`, you may need to add some logic to handle resetting the `pageIndex` yourself to avoid showing empty pages.
+When `autoResetPageIndex` is off or `autoResetAll` is `false` and a data, filter, or grouping change reduces the row count, the table clamps any now-out-of-range `pageIndex` to the last page, so it does not show an empty page. With `manualPagination`, keeping `pageIndex` within the server's page range is still up to you.
@@ -321,7 +321,7 @@
A common reason to set `autoResetPageIndex: false` is editing data while viewing the table (for example, inline cell editing). Every edit updates `data`, which recomputes the row models and would otherwise snap the user back to the first page. Setting the option to a static `false` keeps the current page when the row model recomputes. If you also use the expanding feature, pair it with `autoResetExpanded: false` so expanded rows do not collapse on edits.
-Be aware, however, that if you turn off `autoResetPageIndex`, you may need to add some logic to handle resetting the `pageIndex` yourself to avoid showing empty pages.
+When `autoResetPageIndex` is off or `autoResetAll` is `false` and a data, filter, or grouping change reduces the row count, the table clamps any now-out-of-range `pageIndex` to the last page, so it does not show an empty page. With `manualPagination`, keeping `pageIndex` within the server's page range is still up to you.