fix(ui): forward list filter to bulk actions when selecting all across pages - #17695
Open
luantaraschi wants to merge 1 commit into
Open
fix(ui): forward list filter to bulk actions when selecting all across pages#17695luantaraschi wants to merge 1 commit into
luantaraschi wants to merge 1 commit into
Conversation
…s pages ListSelection accepts a `where` prop and forwards it to EditMany, PublishMany and UnpublishMany, but the two list-view call sites never passed it. Selecting all documents across pages under an active URL filter therefore applied bulk actions to every document matching only the action's base constraint, ignoring the filter. GroupByHeader already passes `where`, and DeleteMany is unaffected because it derives baseWhere from the search params inside ListSelection itself — which is why only Edit/Publish/Unpublish showed the bug. Fixes payloadcms#17670
luantaraschi
requested review from
AlessioGr,
JarrodMFlesch and
jacobsfletch
as code owners
August 6, 2026 20:37
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17670
What?
ListSelectionaccepts awhereprop and forwards it toEditMany,PublishManyandUnpublishMany, but the two main list-view call sites never pass it. This PR forwards the URLwherequery fromuseListQuery()at both call sites.Why?
When an editor filters a list, clicks "Select all N across pages" and then triggers a bulk action, the filter is dropped and the action hits every document matching only the action's base constraint.
The issue reports a concrete case: a collection filtered to 598 documents via
?where[pageType][equals]=atm, bulk Unpublish, and 1772 documents get unpublished instead.Three things in the current code line up with that:
views/List/ListSelection/index.tsxdeclareswhere?: Whereand passes it toEditMany,PublishManyandUnpublishMany.views/List/GroupByHeader/index.tsxalready passeswhere, so the prop is the intended contract — the two list-view call sites are the outliers.DeleteManyis unaffected because it usesbaseWhere, derived fromparseSearchParams(searchParams)insideListSelectionitself. That matches the reported symptom exactly: Delete respects the filter, Edit/Publish/Unpublish do not.Manual row selection is also unaffected, because that path sends
id IN [ids].How?
Two call sites, both reading the same
query.wherethe list view already uses:views/List/ListHeader/index.tsx(desktop) — destructurequeryfromuseListQuery()and passwhere={query?.where}.views/List/index.client.tsx(smallBreak) — passwhere={query?.where};querywas already destructured there for thehasWhereParameffect.Added an e2e test in
test/bulk-edit/e2e.spec.tsthat creates three matching and three non-matching published posts, filters the list, selects all across pages, unpublishes, and asserts that the three non-matching documents are still published.Testing performed
tsc --noEmitonpackages/ui: no new errors introduced. I compared against a baseline run on unmodifiedmainand the output is identical.I was not able to run the e2e suite locally.
pnpm installfails on Windows duringpostinstall:@vercel/git-hooksthrowsEPERM: symlinkwhen creating.git/hooks/applypatch-msg, which aborts the lifecycle and leavesnode_modules/.binunpopulated. Completing the install with--ignore-scriptsgets the workspace linked, but the dependent packages are then unbuilt, sotscreportsTS6305across the package and the Playwright suite can't start.The new test follows the existing
should unpublish manytest in the same file and reusesaddListFilterfromtest/__helpers/e2e/filters, but it has not been executed. Flagging that explicitly rather than implying otherwise — please have CI or a maintainer confirm it fails without the fix and passes with it.Notes for the reviewer
query?.whereis written defensively even thoughIListQueryContext.queryis non-optional, to match the surrounding usage inindex.client.tsx(hasWhereParam, theuseEffectdependency) and in theListQueryprovider itself.I did not touch
HierarchyList/HierarchyListHeader, which also renders a selection component — it usesDocumentListSelectionrather than thisListSelection, so it's a separate path and out of scope here.