From ee617e83368d6c4bb99bb5d5540c4e0b2412e8e1 Mon Sep 17 00:00:00 2001 From: Alec Geatches Date: Fri, 3 Apr 2026 11:55:51 -0600 Subject: [PATCH 1/2] Precompute blockContent to prevent RESET_BLOCKS from interfering with collaborative editing --- .../src/components/block-list/block-html.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block-html.js b/packages/block-editor/src/components/block-list/block-html.js index 5d9e7bfeb7bf77..d2e9f7192e1392 100644 --- a/packages/block-editor/src/components/block-list/block-html.js +++ b/packages/block-editor/src/components/block-list/block-html.js @@ -28,6 +28,13 @@ function BlockHTML( { clientId } ) { [ clientId ] ); const { updateBlock } = useDispatch( blockEditorStore ); + + // Derive block content as a primitive string so the effect only fires + // when the serialized content genuinely changes, not when the block + // object reference changes (which happens on every RESET_BLOCKS during + // RTC sync, even for unchanged blocks). + const blockContent = block ? getBlockContent( block ) : ''; + const onChange = () => { const blockType = getBlockType( block.name ); @@ -64,8 +71,8 @@ function BlockHTML( { clientId } ) { }; useEffect( () => { - setHtml( getBlockContent( block ) ); - }, [ block ] ); + setHtml( blockContent ); + }, [ blockContent ] ); return ( Date: Fri, 3 Apr 2026 12:20:18 -0600 Subject: [PATCH 2/2] Memoize block content to avoid `getBlockContent()` every render --- .../block-editor/src/components/block-list/block-html.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block-html.js b/packages/block-editor/src/components/block-list/block-html.js index d2e9f7192e1392..c670133de17c41 100644 --- a/packages/block-editor/src/components/block-list/block-html.js +++ b/packages/block-editor/src/components/block-list/block-html.js @@ -6,7 +6,7 @@ import TextareaAutosize from 'react-autosize-textarea'; /** * WordPress dependencies */ -import { useEffect, useState } from '@wordpress/element'; +import { useEffect, useMemo, useState } from '@wordpress/element'; import { useSelect, useDispatch } from '@wordpress/data'; import { getBlockAttributes, @@ -33,7 +33,10 @@ function BlockHTML( { clientId } ) { // when the serialized content genuinely changes, not when the block // object reference changes (which happens on every RESET_BLOCKS during // RTC sync, even for unchanged blocks). - const blockContent = block ? getBlockContent( block ) : ''; + const blockContent = useMemo( + () => ( block ? getBlockContent( block ) : '' ), + [ block ] + ); const onChange = () => { const blockType = getBlockType( block.name );