fix(ui): preserve URL where filter on bulk publish/unpublish/edit#16570
Open
dawndarkness wants to merge 1 commit into
Open
fix(ui): preserve URL where filter on bulk publish/unpublish/edit#16570dawndarkness wants to merge 1 commit into
dawndarkness wants to merge 1 commit into
Conversation
The List view did not forward useListQuery()'s `where` to <ListSelection>, so Select-all-N + bulk Publish/Unpublish/Edit dropped the filter and hit every doc matching the action's base constraint. Pass query?.where into <ListSelection>. Downstream merging via combineWhereConstraints already handles it. Adds E2E coverage. Refs payloadcms#16325
70ecfa3 to
d8a9231
Compare
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.
What?
@payloadcms/uiList view drops the URLwherefilter when an editor clicks "Select all N across pages" and then triggers a bulk action (Publish / Unpublish / Edit). The outbound PATCH request hits every document matching the action's base constraint (e.g._status != draftfor Unpublish), ignoring the filter the user had applied.Concrete impact: filter to a subset of a collection (e.g.
?where[pageType][equals]=atm, 598 docs), select all across pages, bulk Unpublish → request unpublishes all published docs in the collection (e.g. 1772), not just the filtered 598.Manual row ticks were unaffected because that path sends
id IN [ids]. Search-only (?search=) was also unaffected because search propagates through a separate code path. Only the structured?where[...]URL param was being dropped.Why?
Both
packages/ui/src/views/List/index.tsx(smallBreak path) andpackages/ui/src/views/List/ListHeader/index.tsx(desktop path) rendered<ListSelection>without forwarding the URLwherefromuseListQuery(). Everything downstream was already wired correctly:views/List/ListSelection/index.tsxacceptswhereand forwards it toEditMany_v4,PublishMany_v4,UnpublishMany_v4.Each drawer merges the prop into its base constraint via
combineWhereConstraints.DeleteManyindependently reads URLwhereviaparseSearchParams(searchParams)?.whereand was unaffected.The missing wiring was in the parent List views (
DefaultListViewandCollectionListHeader).How?
Destructure
queryfromuseListQuery()in bothDefaultListView(smallBreak path,packages/ui/src/views/List/index.tsx) andCollectionListHeader(desktop path,packages/ui/src/views/List/ListHeader/index.tsx), and passquery?.whereinto<ListSelection>at both sites.Without the
ListHeaderwiring,PublishMany/EditManymasked the gap via their ownparseSearchParams(searchParams)?.wherefallback;UnpublishManyhas no such fallback, so the bug was only visible on the unpublish path.Adds three Playwright E2E tests in
test/bulk-edit/e2e.spec.ts(Bulk Edit > preserves URL where filter on bulk actions across pages) that:_status: 'published'explicitly —payload.createdoes NOT default to published for versioned collections (the_statusfield'sdefaultValueis'draft'inversions/baseFields.ts), so adraft: falsearg alone leaves the doc as draft.?where[and][0][title][like]=....The existing "filters and across pages" coverage in this file uses the search
bar (
?search=), which propagates separately, so it never exercised this codepath.
Refs #16325 (same root cause, framed there as a multi-tenant plugin bug).