Skip to content

fix(core): strip currentPage in useTable getCurrentQueryParams - #7630

Open
fncreator22 wants to merge 2 commits into
refinedev:mainfrom
fncreator22:fix/core-usetable-sync-location-current-page
Open

fncreator22 wants to merge 2 commits into
refinedev:mainfrom
fncreator22:fix/core-usetable-sync-location-current-page

Conversation

@fncreator22

Copy link
Copy Markdown

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

In useTable (packages/core/src/hooks/useTable/index.ts), getCurrentQueryParams still destructures the legacy v4 current property instead of currentPage:

const getCurrentQueryParams = (): object => {
  // We get QueryString parameters that are uncontrolled by refine.
  const { sorters, filters, pageSize, current, ...rest } =
    parsedParams?.params ?? {};

  return rest;
};

Because getCurrentQueryParams() is spread after { currentPage, pageSize } inside createLinkForSyncWithLocation:

  1. When currentPage is present in parsedParams.params (e.g. ?currentPage=2), rest.currentPage overwrites the target currentPage passed to createLinkForSyncWithLocation.
  2. When no currentPage query param is in the URL, router bindings (@refinedev/react-router, @refinedev/remix-router, @refinedev/nextjs-router) still define currentPage: undefined on parsedParams.params, which overwrites the target currentPage with undefined.
  3. When pagination.mode is "off", currentPage from parsedParams.params leaks into the link query via ...getCurrentQueryParams().

What is the new behavior?

getCurrentQueryParams now strips currentPage instead of current (matching useMeta and the v5 pagination changes in #6948 and #7015), so createLinkForSyncWithLocation uses the provided currentPage while preserving uncontrolled query parameters.

Notes for reviewers

  • Added unit tests in packages/core/src/hooks/useTable/index.spec.ts covering createLinkForSyncWithLocation both with pagination enabled and with pagination: { mode: "off" }.

@changeset-bot

changeset-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f33ca9f

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

This PR includes changesets to release 1 package
Name Type
@refinedev/core 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

const getCurrentQueryParams = (): object => {
// We get QueryString parameters that are uncontrolled by refine.
const { sorters, filters, pageSize, current, ...rest } =
const { sorters, filters, pageSize, currentPage, ...rest } =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix. I think this should keep stripping the legacy current key as well, rather than replacing it with currentPage because the React Router parser preserves arbitrary query keys in parsedParams.params, so opening an old link such as ?current=2 and then using createLinkForSyncWithLocation for page 3 will produce a link containing both current=2 and currentPage=3. The Ant Design pagination path calls this helper directly so it's quite important.

Could you, please, destructure both current and currentPage, and add a regression test with a legacy current query parameter just in case? Thanks!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, @sviat-barbutsa! Preserving legacy ?current= from old bookmarks while introducing ?currentPage= would indeed pollute the query string.

I've updated getCurrentQueryParams to strip both current and currentPage, and added a dedicated regression test verifying that legacy current is cleanly stripped alongside currentPage. Thank you for the thoughtful review!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fncreator22 thank you for your reaction and update. Glad to help!

This branch has not been deployed

No deployments
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.

2 participants