You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: v4 single-locale publish pairs block/array rows by index, not id #18678
When a single locale is published (a non-draft update with one locale), buildLocalizedPublishData calls mergeLocalizedData, which pairs array and block rows with the stored rows by index (L132, L184) instead of by id. Each merged row starts as a copy of that stored row (L95), so when the row at an index changes (reorder, insert, delete, block type change):
Reordered array rows swap their other-locale values. Swap two rows and publish en: each row now has the other row's de value. This silently corrupts a locale nobody edited, with the default storage.
A new block inherits the fields of the block previously at its index. Replacing an alpha block (a, alphaLabel) with a beta block (b) stores { blockType: 'beta', b, a, alphaLabel }, persisted with blocksAsJSON: true.
v4 enables localizeStatus automatically, so every localized collection with drafts is affected. The merge runs after all hooks, so it can't be worked around in a hook.
Suggested fix: match the stored row by id (for blocks also by blockType), falling back to {}, like getExistingRowDoc does. With that change both tests pass:
Clone this repo and open the single-locale-publish-leaks-stale-row-fields-v4/ directory
pnpm install
pnpm test:int: both tests fail
FAIL keeps the other locale of an array row with that row when rows are reordered
- Expected: [["second", "Zweite"], ["first", "Erste"]]
+ Received: [["second", "Erste"], ["first", "Zweite"]]
FAIL does not carry fields of the previous block at the same index into a new block
stored block: { blockType: 'beta', a: 'from alpha', alphaLabel: { en: 'alpha label' }, id: '…', b: 'from beta' }
Activity
fix(core): match array and block rows by id in mergeLocalizedData (pa…