payload icon indicating copy to clipboard operation
payload copied to clipboard

Handle optional fields in upload collections with filesRequiredOnCreate: false

Open barthy-koeln opened this issue 1 year ago • 0 comments

Describe the Bug

An upload collection with filesRequiredOnCreate: false will run into an issue in any UI element because RelationshipContent does not properly verify the existence of a mime type.

Code to fix: packages/ui/src/fields/Upload/RelationshipContent/index.tsx

Several props must be optional:

  • mimeType
  • filename
  • byteSize
  • src

Link to the code that reproduces this issue

https://github.com/barthy-koeln/payload-repro-missing-mime

Reproduction Steps

  1. Run the project and log in with [email protected] for both user and admin, or create a new DB and a new user.
  2. Open the user edit form and select the existing image that does not have an uploaded file.

Which area(s) are affected? (Select all that apply)

area: ui

Environment Info

Binaries:
  Node: 22.9.0
  npm: 10.9.0
  Yarn: 1.22.22
  pnpm: 9.14.4
Relevant Packages:
  payload: 3.4.0
  next: 15.0.3
  @payloadcms/email-nodemailer: 3.4.0
  @payloadcms/graphql: 3.4.0
  @payloadcms/next/utilities: 3.4.0
  @payloadcms/payload-cloud: 3.4.0
  @payloadcms/richtext-lexical: 3.4.0
  @payloadcms/translations: 3.4.0
  @payloadcms/ui/shared: 3.4.0
  react: 19.0.0-rc-66855b96-20241106
  react-dom: 19.0.0-rc-66855b96-20241106
Operating System:
  Platform: darwin
  Arch: arm64

barthy-koeln avatar Dec 06 '24 08:12 barthy-koeln