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 Aug 19, 2023
1 parent b49ff74 commit 302bbe4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/table-core/src/features/Pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,23 @@ export const Pagination: 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
if (currentPageIndex > table.getPageCount() - 1) {
table.setPageIndex(currentPageIndex - 1)
}
}
queued = false
})
}
Expand Down

0 comments on commit 302bbe4

Please sign in to comment.