Skip to content

Polymorphic hasMany upload bulk select saves selected docs with wrong relationTo #16696

Description

@damnsamn

Describe the Bug

When using a polymorphic upload field with hasMany: true, selecting existing uploads via the checkbox bulk-selection flow can save the selected document IDs with the wrong relationTo.

Selecting a single row by clicking the first column works correctly. The issue only appears when using the checkbox bulk-select path, even if only one item is selected.

Link to the code that reproduces this issue

https://github.com/damnsamn/blank-payload-project/tree/repro/polymorphic-upload-bulk-select

Reproduction Steps

  1. Configure a polymorphic upload field with multiple upload-enabled collections, e.g. images and videos.
  2. Open the field’s “Select existing” drawer.
  3. Change the drawer collection dropdown from the first collection to the second collection.
  4. Select one or more documents using the row checkboxes.
  5. Click “Select”.
  6. Save the document.

See video:

Kapture.2026-05-20.at.16.40.44.mp4

Expected behavior

Selected documents should be saved with the collection selected in the drawer dropdown, e.g.

{
  relationTo: 'videos',
  value: '<video-id>'
}

Actual behavior

Selected documents are saved with the first configured upload collection as relationTo, e.g.

{
  relationTo: 'images',
  value: '<video-id>'
}

This creates broken relationships because the ID belongs to the second collection, not the first.

Which area(s) are affected?

area: core

Environment Info

Binaries:
  Node: 26.0.0
  npm: 11.12.1
  Yarn: 1.22.22
  pnpm: 10.33.0
Relevant Packages:
  payload: 3.78.0
  next: 15.4.11
  @payloadcms/db-mongodb: 3.78.0
  @payloadcms/graphql: 3.78.0
  @payloadcms/next/utilities: 3.78.0
  @payloadcms/richtext-lexical: 3.78.0
  @payloadcms/translations: 3.78.0
  @payloadcms/ui/shared: 3.78.0
  react: 19.2.1
  react-dom: 19.2.1
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:31 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6030
  Available memory (MB): 18432
  Available CPU cores: 12

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions