fix(pagination): autoResetPageIndex should reset to 0, not initialState pageIndex#6208
fix(pagination): autoResetPageIndex should reset to 0, not initialState pageIndex#6208sleitor wants to merge 1 commit intoTanStack:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can customize the high-level summary generated by CodeRabbit.Configure the |
Summary
Fixes #6207
When
autoResetPageIndexfires (e.g. after data/filter changes), it now callstable.resetPageIndex(true)to reset to0(the default page) instead oftable.resetPageIndex()which resets toinitialState.pagination.pageIndex.Root cause
In
RowPagination.ts,_autoResetPageIndexcalledtable.resetPageIndex()withoutdefaultState = true:This caused issues when
initialState.pagination.pageIndexwas set to a non-zero value (e.g. restored from URL params). After a filter change that reduced total pages, the table would reset to the initial page (e.g. page 5) rather than page 0, leaving users on an empty/invalid page.Changes
packages/table-core/src/features/RowPagination.ts: passtruetoresetPageIndex()in_autoResetPageIndex@tanstack/table-core