Skip to content

Commit

Permalink
Fix an issue where pageIndex becomes invalid when data is changed (re…
Browse files Browse the repository at this point in the history
…moved) and autoResetPageIndex is false.
  • Loading branch information
hamidvirani committed Mar 19, 2024
1 parent 65af403 commit d5066e9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/table-core/src/features/RowPagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,24 @@ export const RowPagination: TableFeature = {
}

if (
table.options.autoResetAll ??
table.options.autoResetPageIndex ??
table.getState().pagination &&
!table.options.manualPagination
) {
if (queued) return
queued = true
table._queue(() => {
table.resetPageIndex()
if (
table.options.autoResetAll ??
table.options.autoResetPageIndex
) {
table.resetPageIndex()
} else {
const currentPageIndex = table.getState().pagination.pageIndex
const lastPageIndex = table.getPageCount() - 1
if (currentPageIndex > lastPageIndex) {
table.setPageIndex(lastPageIndex)
}
}
queued = false
})
}
Expand Down

0 comments on commit d5066e9

Please sign in to comment.