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 20, 2023
1 parent b49ff74 commit bb83e52
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 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,24 @@ 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
const lastPageIndex = table.getPageCount() - 1
if (currentPageIndex > lastPageIndex) {
table.setPageIndex(lastPageIndex)
}
}
queued = false
})
}
Expand Down

0 comments on commit bb83e52

Please sign in to comment.