payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
29.26k stars 1.81k forks source link

Two array fields with single upload field breaks admin data loading. #8690

Closed ckruppe closed 1 month ago

ckruppe commented 1 month ago

Link to reproduction

No response

Environment Info

Binaries: Node: 20.11.1 npm: N/A Yarn: N/A pnpm: N/A Relevant Packages: payload: 3.0.0-beta.113 next: 15.0.0-canary.173 @payloadcms/db-mongodb: 3.0.0-beta.113 @payloadcms/graphql: 3.0.0-beta.113 @payloadcms/live-preview: 3.0.0-beta.113 @payloadcms/live-preview-react: 3.0.0-beta.113 @payloadcms/next/utilities: 3.0.0-beta.113 @payloadcms/plugin-nested-docs: 3.0.0-beta.113 @payloadcms/plugin-seo: 3.0.0-beta.113 @payloadcms/richtext-lexical: 3.0.0-beta.113 @payloadcms/richtext-slate: 3.0.0-beta.113 @payloadcms/translations: 3.0.0-beta.113 @payloadcms/ui/shared: 3.0.0-beta.113 react: 19.0.0-rc-3edc000d-20240926 react-dom: 19.0.0-rc-3edc000d-20240926 Operating System: Platform: win32 Arch: x64 Version: Windows 11 Pro Available memory (MB): 32488 Available CPU cores: 16

Describe the Bug

Havingf two array fields with one upload each breaks the data loading in admin edit view. The first array gets saved but not loaded in admin panel (it appears empty). The second gets loaded correctly. Database Entry:

{
  "_id": {
    "$oid": "670d31fed4b7c94af3766024"
  },
  "name": "Test",
  "slider": [
    {
      "data": "670d317ed4b7c94af3765f83",
      "id": "670d31fe6194a5b41856b646"
    },
    {
      "data": "670d31a3d4b7c94af3765fc0",
      "id": "670d31fe6194a5b41856b647"
    },
    {
      "data": "670d31f3d4b7c94af3765ffd",
      "id": "670d31fe6194a5b41856b648"
    }
  ],
  "createdAt": {
    "$date": "2024-10-14T15:00:14.084Z"
  },
  "updatedAt": {
    "$date": "2024-10-14T15:05:11.215Z"
  },
  "__v": 0,
  "content": [
    {
      "contentData": "670d31f3d4b7c94af3765ffd",
      "id": "670d330a32ca0cb418cbe246"
    },
    {
      "contentData": "670d315cd4b7c94af3765f09",
      "id": "670d331132ca0cb418cbe247"
    },
    {
      "contentData": "670d316fd4b7c94af3765f46",
      "id": "670d332032ca0cb418cbe248"
    }
  ]
}

The admin after reloading: Image

The Collection config:

export const Products: CollectionConfig = {
    access: {
        admin: authenticated,
        create: authenticated,
        delete: authenticated,
        read: authenticated,
        update: authenticated
    },
    admin: {
        defaultColumns: ['name', 'createdAt', 'updatedAt'],
        description: 'Eine Liste aller Admin-User.',
        group: 'App Daten',
        useAsTitle: 'name'
    },
    fields: [
        {
            label: 'Name',
            name: 'name',
            required: true,
            type: 'text'
        },
        {
            editor: lexicalEditor({
                /**
                 *
                 */
                features() {
                    return [
                        InlineToolbarFeature(),
                        UnderlineFeature(),
                        ItalicFeature(),
                        ParagraphFeature(),
                        BoldFeature(),
                        HeadingFeature({enabledHeadingSizes: ['h1', 'h2', 'h3', 'h4']}),
                        UnorderedListFeature()
                    ];
                }
            }),
            label: 'Beschreibung',
            name: 'description',
            type: 'richText'
        },
        {
            fields: [
                {
                    displayPreview: true,
                    label: 'Content',
                    name: 'contentData',
                    relationTo: 'media',
                    required: true,
                    type: 'upload'
                }
            ],
            label: 'Media Content',
            name: 'content',
            type: 'array'
        },
        {
            fields: [
                {
                    displayPreview: true,
                    label: 'Content',
                    name: 'data',
                    relationTo: 'media',
                    required: true,
                    type: 'upload'
                }
            ],
            label: 'Slider Content',
            name: 'slider',
            type: 'array'
        },
        {
            collection: 'image-maps',
            label: 'Zugehörige Image Maps',
            name: 'relatedImageMaps',
            on: 'hotspots.products',
            type: 'join'
        }
    ],
    slug: 'products'
};

Reproduction Steps

1.) Create an collection like above. 2.) Upload data into both arrays. 3.) Reload page.

Adapters and Plugins

No response

ckruppe commented 1 month ago

Update: If i split up both array fields in their own tabs it is working again.

github-actions[bot] commented 1 month ago

🚀 This is included in version v3.0.0-beta.115

github-actions[bot] commented 1 month ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.