Skip to content

fix: localized array,group,blocks fields duplicate with empty values#15849

Merged
JarrodMFlesch merged 2 commits into
payloadcms:mainfrom
jakobpevec:fix/15847-empty-value-of-localized-fields-when-duplicating
Apr 9, 2026
Merged

fix: localized array,group,blocks fields duplicate with empty values#15849
JarrodMFlesch merged 2 commits into
payloadcms:mainfrom
jakobpevec:fix/15847-empty-value-of-localized-fields-when-duplicating

Conversation

@jakobpevec

Copy link
Copy Markdown
Contributor

What?

Localized blocks, array, and group fields are empty when
duplicating a selected locale.

Why?

filterDataToSelectedLocales assumed field types (blocks,
array, group) always stored data directly as arrays. When
these fields are localized, data is wrapped in a locale map ({ en:
[...], de: [...] }), which was not being unwrapped before
processing.

How?

  • Added locale-aware branching for blocks, array, and group field
    types — when the field is localized, the locale map is filtered
    first, then each locale's value is recursed into
  • Extracted a filterLocaleMap helper to consistently filter and
    transform locale maps across all field types
  • Added unit tests

Fixes #15847

@jakobpevec jakobpevec changed the title Fix: Localized array,group,blocks fields duplicate with empty values fix: Localized array,group,blocks fields duplicate with empty values Mar 5, 2026
@jakobpevec jakobpevec changed the title fix: Localized array,group,blocks fields duplicate with empty values fix: localized array,group,blocks fields duplicate with empty values Mar 5, 2026
…y duplicated during selected locale duplication
@JarrodMFlesch JarrodMFlesch self-assigned this Apr 8, 2026
@JarrodMFlesch JarrodMFlesch reopened this Apr 8, 2026
@JarrodMFlesch JarrodMFlesch merged commit 067e14f into payloadcms:main Apr 9, 2026
467 of 471 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.83.0

milamer pushed a commit to milamer/payload that referenced this pull request Apr 20, 2026
…ayloadcms#15849)

### What?
  Localized blocks, array, and group fields are empty when           
  duplicating a selected locale.

### Why?
filterDataToSelectedLocales assumed field types (blocks,
  array, group) always stored data directly as arrays. When
  these fields are localized, data is wrapped in a locale map ({ en:
  [...], de: [...] }), which was not being unwrapped before
  processing.

### How?
 - Added locale-aware branching for blocks, array, and group field
  types — when the field is localized, the locale map is filtered
  first, then each locale's value is recursed into
  - Extracted a filterLocaleMap helper to consistently filter and
  transform locale maps across all field types
  - Added unit tests

Fixes payloadcms#15847

---------

Co-authored-by: pevecj <jakob.pevec@renderspace.si>
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.

Bug: Duplicating a selected locale copies empty values for localized block fields

3 participants