Skip to content

Fix <PrevNextButtons storeKey={false}> being ignored - #11371

Merged
fzaninotto merged 1 commit into
marmelab:masterfrom
Sophran-fbj:fix-prevnextbuttons-store-key-false
Sep 14, 2026
Merged

fzaninotto merged 1 commit into
marmelab:masterfrom
Sophran-fbj:fix-prevnextbuttons-store-key-false

Conversation

@Sophran-fbj

Copy link
Copy Markdown

Problem

<PrevNextButtons storeKey={false}> had no effect — it behaved exactly like omitting the prop (#11370). usePrevNextController used the stored list params unconditionally: when storeKey was false, the useStore call fell back to the default `${resource}.listParams` key, so the list's stored sort and filters leaked into the pager's getList call, overriding the sort, filter and filterDefaultValues props.

Solution

Mirror what useListParams has done since #9742: keep calling useStore unconditionally (hooks can't be conditional), but ignore its value when storeKey is strictly false, falling back to the props-derived defaults. Passing no storeKey (undefined) keeps the previous behavior of syncing with the list.

How To Test

  • New WithoutStoreKey story and a regression test in PrevNextButtons.spec.tsx: filter a list (stores { q: ... } under customers.listParams), then open a record with <PrevNextButtons storeKey={false} sort={{ field: 'first_name', order: 'DESC' }} />. The pager must issue getList with sort: { field: 'first_name', order: 'DESC' } and filter: {} (position 11 / 900), ignoring the stored filter.
  • The existing WithQueryFilter test covers the opposite (default) behavior: without storeKey, the pager follows the list's stored filter (10 / 50).
  • The new test fails on master and passes with this change; the other 17 tests of the suite are unaffected.

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date

Fixes #11370

usePrevNextController used the stored list params unconditionally:
when storeKey was false, the useStore call fell back to the default
`${resource}.listParams` key, so the pager silently synced with the
list's stored sort and filters instead of relying on its own props.

<List> got the full "disable store interactions" treatment in marmelab#9742;
mirror useListParams here: keep calling useStore unconditionally
(hooks rules), but ignore its value when storeKey is strictly false.

Fixes marmelab#11370

Co-Authored-By: Claude <noreply@anthropic.com>
@fzaninotto
fzaninotto merged commit ca98b00 into marmelab:master Sep 14, 2026
14 checks passed
@fzaninotto

Copy link
Copy Markdown
Member

Thanks!

@fzaninotto fzaninotto added this to the 5.15.4 milestone Sep 14, 2026
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.

<PrevNextButtons storeKey={false}> has no effect

2 participants