Skip to content

Commit 7d982a7

Browse files
alecgeatcheschriszarate
authored andcommitted
Return original blocks when controlledBlocks represent post content in a template for UUID-based awareness features to work
1 parent 5f6fcd3 commit 7d982a7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

packages/block-editor/src/components/provider/use-block-sync.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,25 @@ export default function useBlockSync( {
104104
// and so it would already be persisted.
105105
__unstableMarkNextChangeAsNotPersistent();
106106
if ( clientId ) {
107+
const blockName = getBlockName( clientId );
108+
const isPostContentBlock = blockName === 'core/post-content';
109+
107110
// It is important to batch here because otherwise,
108111
// as soon as `setHasControlledInnerBlocks` is called
109112
// the effect to restore might be triggered
110113
// before the actual blocks get set properly in state.
111114
registry.batch( () => {
112115
setHasControlledInnerBlocks( clientId, true );
113-
const storeBlocks = controlledBlocks.map( ( block ) =>
114-
cloneBlock( block )
115-
);
116+
117+
// For post-content block children, preserve the
118+
// original blocks to maintain UUIDs used for
119+
// multi-user collaboration
120+
//
121+
// Unsure: Why are these blocks being cloned? Do they need to be?
122+
const storeBlocks = isPostContentBlock
123+
? controlledBlocks
124+
: controlledBlocks.map( ( block ) => cloneBlock( block ) );
125+
116126
if ( subscribedRef.current ) {
117127
pendingChangesRef.current.incoming = storeBlocks;
118128
}

0 commit comments

Comments
 (0)