diff --git a/packages/blocks/src/api/templates.js b/packages/blocks/src/api/templates.js index d09be49453e70..c23893fa6e49c 100644 --- a/packages/blocks/src/api/templates.js +++ b/packages/blocks/src/api/templates.js @@ -57,11 +57,6 @@ export function synchronizeBlocksWithTemplate( blocks = [], template ) { return map( template, ( [ name, attributes, innerBlocksTemplate ], index ) => { const block = blocks[ index ]; - if ( block && block.name === name ) { - const innerBlocks = synchronizeBlocksWithTemplate( block.innerBlocks, innerBlocksTemplate ); - return { ...block, innerBlocks }; - } - // To support old templates that were using the "children" format // for the attributes using "html" strings now, we normalize the template attributes // before creating the blocks. @@ -97,6 +92,11 @@ export function synchronizeBlocksWithTemplate( blocks = [], template ) { attributes ); + if ( block && block.name === name ) { + const innerBlocks = synchronizeBlocksWithTemplate( block.innerBlocks, innerBlocksTemplate ); + return { ...block, attributes: normalizedAttributes, innerBlocks }; + } + return createBlock( name, normalizedAttributes,