From a1d6d87c52156a6f477f1389f18af9de7b4c6780 Mon Sep 17 00:00:00 2001 From: Ella Date: Thu, 25 Apr 2024 22:26:26 +0300 Subject: [PATCH] useBlockSync: just testing without isControlled effect --- .../src/components/provider/use-block-sync.js | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/packages/block-editor/src/components/provider/use-block-sync.js b/packages/block-editor/src/components/provider/use-block-sync.js index 7dfbd6a8f320e..f266251759dfe 100644 --- a/packages/block-editor/src/components/provider/use-block-sync.js +++ b/packages/block-editor/src/components/provider/use-block-sync.js @@ -2,7 +2,7 @@ * WordPress dependencies */ import { useEffect, useRef } from '@wordpress/element'; -import { useRegistry, useSelect } from '@wordpress/data'; +import { useRegistry } from '@wordpress/data'; import { cloneBlock } from '@wordpress/blocks'; /** @@ -82,15 +82,6 @@ export default function useBlockSync( { } = registry.dispatch( blockEditorStore ); const { getBlockName, getBlocks, getSelectionStart, getSelectionEnd } = registry.select( blockEditorStore ); - const isControlled = useSelect( - ( select ) => { - return ( - ! clientId || - select( blockEditorStore ).areInnerBlocksControlled( clientId ) - ); - }, - [ clientId ] - ); const pendingChanges = useRef( { incoming: null, outgoing: [] } ); const subscribed = useRef( false ); @@ -186,23 +177,6 @@ export default function useBlockSync( { } }, [ controlledBlocks, clientId ] ); - const isMounted = useRef( false ); - - useEffect( () => { - // On mount, controlled blocks are already set in the effect above. - if ( ! isMounted.current ) { - isMounted.current = true; - return; - } - - // When the block becomes uncontrolled, it means its inner state has been reset - // we need to take the blocks again from the external value property. - if ( ! isControlled ) { - pendingChanges.current.outgoing = []; - setControlledBlocks(); - } - }, [ isControlled ] ); - useEffect( () => { const { getSelectedBlocksInitialCaretPosition,