Skip to content

When copying or saving to a locale, the localized fields in arrays or blocks of other locales lose their values #12536

@epranka

Description

@epranka

Describe the Bug

If a collection contains arrays or blocks with localized fields, copying one locale to another or simply saving the current locale causes other locales to lose their values. It seems that localized values are not merged but instead overwritten. I am using MongoDB, so I'm not sure if this behavior is different with relational databases

Link to the code that reproduces this issue

https://github.com/epranka/payload-locales-save-issue

Reproduction Steps

  1. Clone the repository.
  2. Run docker compose up and wait until both the app and MongoDB are ready.
  3. Open http://localhost:3000/admin.
  4. Create an account.
  5. Create a new Page. Enter a title, add at least one item in an array or block with filled fields. In the Content tab, add any layout to avoid validation errors. Then, publish the page.
  6. Click "Copy to locale" and select the "en" locale.
  7. Switch back to the previous "lt" locale. You should see that the values in the array and block are lost.
  8. Click "Copy to locale" and select the "lt" locale.
  9. Switch back to the previous "en" locale. You should now see that the values are lost in that locale instead. Only the last saved locale retains its values.

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

Not sure

Environment Info

Binaries:
  Node: 20.13.1
  npm: 10.5.2
  Yarn: N/A
  pnpm: 10.11.0
Relevant Packages:
  payload: 3.39.1
  next: 15.3.0
  @payloadcms/db-mongodb: 3.39.1
  @payloadcms/email-nodemailer: 3.39.1
  @payloadcms/graphql: 3.39.1
  @payloadcms/live-preview: 3.39.1
  @payloadcms/live-preview-react: 3.39.1
  @payloadcms/next/utilities: 3.39.1
  @payloadcms/payload-cloud: 3.39.1
  @payloadcms/plugin-form-builder: 3.39.1
  @payloadcms/plugin-nested-docs: 3.39.1
  @payloadcms/plugin-redirects: 3.39.1
  @payloadcms/plugin-search: 3.39.1
  @payloadcms/plugin-seo: 3.39.1
  @payloadcms/richtext-lexical: 3.39.1
  @payloadcms/translations: 3.39.1
  @payloadcms/ui/shared: 3.39.1
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #61.1~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Apr 18 12:20:24 UTC
  Available memory (MB): 64167
  Available CPU cores: 16

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions