Skip to content

Commit

Permalink
[Pattern Overrides] Fix duplication of inner blocks (#57538)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 authored Jan 5, 2024
1 parent 915296f commit 6f61d8b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/block-library/src/block/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
store as blockEditorStore,
BlockControls,
} from '@wordpress/block-editor';
import { getBlockSupport, parse } from '@wordpress/blocks';
import { getBlockSupport, parse, cloneBlock } from '@wordpress/blocks';

/**
* Internal dependencies
Expand Down Expand Up @@ -205,7 +205,8 @@ export default function ReusableBlockEdit( {
// Apply the initial overrides from the pattern block to the inner blocks.
useEffect( () => {
const initialBlocks =
editedRecord.blocks ??
// Clone the blocks to generate new client IDs.
editedRecord.blocks?.map( ( block ) => cloneBlock( block ) ) ??
( editedRecord.content && typeof editedRecord.content !== 'function'
? parse( editedRecord.content )
: [] );
Expand Down

0 comments on commit 6f61d8b

Please sign in to comment.