Skip to content

fix(ui): preserve polymorphic upload bulk select relation#16695

Open
damnsamn wants to merge 1 commit into
payloadcms:mainfrom
damnsamn:fix/polymorphic-upload-has-many-select
Open

fix(ui): preserve polymorphic upload bulk select relation#16695
damnsamn wants to merge 1 commit into
payloadcms:mainfrom
damnsamn:fix/polymorphic-upload-has-many-select

Conversation

@damnsamn
Copy link
Copy Markdown
Contributor

@damnsamn damnsamn commented May 20, 2026

What?

Fixes polymorphic upload fields with hasMany enabled when selecting existing documents via the list drawer checkbox flow.

Previously, bulk-selecting documents from a non-first upload collection saved the selected IDs with the first configured relationTo collection. For example, selecting documents from uploads-2 could save values as uploads-1 relationships with IDs that do not exist in uploads-1.

Why?

The single row-click selection path already receives the active row collection slug and saves the correct polymorphic relationship. The checkbox bulk-selection path only received selected IDs, so UploadInput fell back to its initial activeRelationTo, which is the first configured collection.

This caused broken polymorphic upload values whenever the drawer collection dropdown was changed before using checkbox selection.

How?

  • Pass the list drawer's currently selected collection slug into onBulkSelect.
  • Use that collection slug when building polymorphic upload values and loading selected docs.
  • Add an e2e regression that creates an upload through the admin UI, switches the polymorphic upload drawer to the second collection, selects via checkbox, saves, and verifies the stored relationTo is preserved.

Fixes #16696

@damnsamn damnsamn marked this pull request as ready for review May 20, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Polymorphic hasMany upload bulk select saves selected docs with wrong relationTo

1 participant