volto icon indicating copy to clipboard operation
volto copied to clipboard

Fix blocks_layout sync when content has empty blocks fields from migr…

Open aryan7081 opened this issue 2 months ago • 2 comments

Fixes #2887

When content has empty blocks={} and blocks_layout={items:[]} adding text to blocks created new block IDs in the blocks field but blocks_layout remained empty, causing view breakage.

This happened because changeBlock only updated the blocks field and getOnlyFormModifiedValues didn't include blocks_layout in the save operation, so the server never received the synchronized blocks_layout update.

This fix adds ensureBlocksLayoutSync helper to synchronize blocks_layout with blocks, updates changeBlock to use it, and modifies getOnlyFormModifiedValues to include blocks_layout when blocks is modified.

aryan7081 avatar Oct 21 '25 18:10 aryan7081

@wesleybl Can you please help me understand why blocks-search.js is failing? It seems unrelated to the changes in this branch.

aryan7081 avatar Oct 31 '25 04:10 aryan7081

@aryan7081 For some reason, with these modifications, when adding a search block, two blocks are added.

wesleybl avatar Oct 31 '25 15:10 wesleybl