fix: Empty localized blocks when duplicating document (#15847)#16560
Open
deepshekhardas wants to merge 3 commits intopayloadcms:mainfrom
Open
fix: Empty localized blocks when duplicating document (#15847)#16560deepshekhardas wants to merge 3 commits intopayloadcms:mainfrom
deepshekhardas wants to merge 3 commits intopayloadcms:mainfrom
Conversation
… with empty value as result.
…y duplicated during selected locale duplication
When duplicating a localized blocks field, the block lookup was iterating through all blockReferences but never finding the matching blockType. Fixed the logic to use Array.find() instead of a for-loop to properly match blockType against block references. Added test cases for localized blocks with both simple and localized child fields to prevent regression.
Contributor
|
Pull Request titles must follow the Conventional Commits specification and have valid scopes. The subject "Empty localized blocks when duplicating document (#15847)" found in the pull request title "fix: Empty localized blocks when duplicating document (#15847)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When duplicating a single locale, any blocks fields with localization enabled are empty in the duplicated document. This prevents editors from creating locale-specific copies of a document.
Root Cause
The
filterDataToSelectedLocalesutility was iterating through allblockReferencesbut never finding the matchingblockTypebecause:Fix
Changed the block lookup logic to use
Array.find()instead of a for-loop, which:Changes
packages/payload/src/utilities/filterDataToSelectedLocales.ts- Fixed block lookup logicpackages/payload/src/utilities/filterDataToSelectedLocales.spec.ts- Added test cases for localized blocksTesting
Related Issues
Fixes #15847