From 020d9f39192fb148f21643527cf76cdb4cca2a5a Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 15 Dec 2022 15:39:36 +0000 Subject: [PATCH] Remove regressed useForcedLayout logic --- .../cart-checkout-shared/use-forced-layout.ts | 57 +------------------ 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout-shared/use-forced-layout.ts b/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout-shared/use-forced-layout.ts index 9b0fa88c338..72183567f0c 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout-shared/use-forced-layout.ts +++ b/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout-shared/use-forced-layout.ts @@ -122,62 +122,7 @@ export const useForcedLayout = ( { .select( 'core/block-editor' ) .getBlocks( clientId ); - const { innerBlocks, registeredBlockTypes } = useSelect( - ( select ) => { - return { - innerBlocks: - select( 'core/block-editor' ).getBlocks( clientId ), - registeredBlockTypes: currentRegisteredBlocks.current.map( - ( blockName ) => getBlockType( blockName ) - ), - }; - }, - [ clientId, currentRegisteredBlocks.current ] - ); - - const appendBlock = useCallback( - ( block, position ) => { - const newBlock = createBlock( block.name ); - insertBlock( newBlock, position, clientId, false ); - }, - // We need to skip insertBlock here due to a cache issue in wordpress.com that causes an infinite loop, see https://github.com/Automattic/wp-calypso/issues/66092 for an expanded doc. - // eslint-disable-next-line react-hooks/exhaustive-deps - [ clientId ] - ); - - const lockedBlockTypes = useMemo( - () => - registeredBlockTypes.filter( - ( block: Block | undefined ) => block && isBlockLocked( block ) - ), - [ registeredBlockTypes ] - ) as Block[]; - - /** - * If the current inner blocks differ from the registered blocks, push the differences. - */ - useLayoutEffect( () => { - if ( ! clientId ) { - return; - } - - // If there are NO inner blocks, sync with the given template. - if ( - innerBlocks.length === 0 && - currentDefaultTemplate.current.length > 0 - ) { - const nextBlocks = createBlocksFromInnerBlocksTemplate( - currentDefaultTemplate.current - ); - if ( ! isEqual( nextBlocks, innerBlocks ) ) { - replaceInnerBlocks( clientId, nextBlocks ); - return; - } - } - - // Find registered locked blocks missing from Inner Blocks and append them. - lockedBlockTypes.forEach( ( block ) => { - // If the locked block type is already in the layout, we can skip this one. + // If there are NO inner blocks, sync with the given template. if ( innerBlocks.length === 0 && currentDefaultTemplate.current.length > 0