From 99dd19a1a5ff88b74cbff682b4650605883a5c8b Mon Sep 17 00:00:00 2001 From: Thomas Roberts <5656702+opr@users.noreply.github.com> Date: Fri, 21 Oct 2022 16:03:14 +0100 Subject: [PATCH] Revert "Fix `useForcedLayout` to re-select inner blocks after we manually insert one (#6676)" (#7447) This reverts commit 1564de216dadf8dd7d7ef7eba70dd10ba1e0fc91. --- .../js/blocks/cart-checkout-shared/use-forced-layout.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/assets/js/blocks/cart-checkout-shared/use-forced-layout.ts b/assets/js/blocks/cart-checkout-shared/use-forced-layout.ts index 47208c98127..6e6d0895bb4 100644 --- a/assets/js/blocks/cart-checkout-shared/use-forced-layout.ts +++ b/assets/js/blocks/cart-checkout-shared/use-forced-layout.ts @@ -6,7 +6,6 @@ import { useRef, useCallback, useMemo, - useState, } from '@wordpress/element'; import { useSelect, useDispatch } from '@wordpress/data'; import { @@ -42,8 +41,6 @@ export const useForcedLayout = ( { } ): void => { const currentRegisteredBlocks = useRef( registeredBlocks ); const currentDefaultTemplate = useRef( defaultTemplate ); - const [ forcedBlocksInserted, setForcedBlocksInserted ] = - useState< number >( 0 ); const { insertBlock, replaceInnerBlocks } = useDispatch( 'core/block-editor' ); @@ -58,18 +55,17 @@ export const useForcedLayout = ( { ), }; }, - [ clientId, currentRegisteredBlocks.current, forcedBlocksInserted ] + [ clientId, currentRegisteredBlocks.current ] ); const appendBlock = useCallback( ( block, position ) => { const newBlock = createBlock( block.name ); insertBlock( newBlock, position, clientId, false ); - setForcedBlocksInserted( forcedBlocksInserted + 1 ); }, // We need to skip insertBlock here due to a cache issue in wordpress.com that causes an inifinite loop, see https://github.com/Automattic/wp-calypso/issues/66092 for an expanded doc. // eslint-disable-next-line react-hooks/exhaustive-deps - [ clientId, forcedBlocksInserted ] + [ clientId ] ); const lockedBlockTypes = useMemo(