Skip to content

fix(react-table): only reset the current page when filters or sorters actually change - #7512

Open
MarioRial22 wants to merge 1 commit into
refinedev:mainfrom
rialestate:fix/react-table-guard-page-reset
Open

fix(react-table): only reset the current page when filters or sorters actually change#7512
MarioRial22 wants to merge 1 commit into
refinedev:mainfrom
rialestate:fix/react-table-guard-page-reset

Conversation

@MarioRial22

Copy link
Copy Markdown

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

useTable's columnFilters/sorting sync effects reset currentPage to 1 on every effect re-run while a filter or sort is active — the isEqual guard covers setFilters/setSorters but not the page reset:

if (!isEqual(crudFilters, filtersCore)) {
  setFilters(crudFilters);
}

if (crudFilters.length > 0 && isPaginationEnabled && !isFirstRender) {
  setCurrentPage(1); // fires on every re-run, not only on real changes
}

… actually change

The columnFilters/sorting sync effects reset currentPage to 1 on every
effect re-run with a non-empty filter/sort — the isEqual guard covered
setFilters/setSorters but not the page reset. The filters effect is
keyed on [columnFilters, columns], so any columns identity change
re-fired it; with syncWithLocation, useNavigation()'s callbacks are
location-sensitive, so columns memoized over them are recreated by the
pagination click's own URL push: page 2 was fetched and immediately
snapped back to page 1.

Move both resets inside their isEqual guards. A real filter/sorter
change still resets the page (covered by a new spec), identity churn
no longer does (covered by a new spec that fails on the previous
implementation), and deep links keep working via the existing
isFirstRender guard.
@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4aa2e10

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/react-table Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant