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 72183567f0c..72068736f5f 100644 --- a/assets/js/blocks/cart-checkout-shared/use-forced-layout.ts +++ b/assets/js/blocks/cart-checkout-shared/use-forced-layout.ts @@ -10,7 +10,6 @@ import { BlockInstance, } from '@wordpress/blocks'; import type { Block, TemplateArray } from '@wordpress/blocks'; -import { isEqual } from 'lodash'; import { MutableRefObject } from 'react'; interface LockableBlock extends Block { @@ -116,6 +115,7 @@ export const useForcedLayout = ( { const registry = useRegistry(); useEffect( () => { + let templateSynced = false; const { replaceInnerBlocks } = dispatch( 'core/block-editor' ); return registry.subscribe( () => { const innerBlocks = registry @@ -125,12 +125,14 @@ export const useForcedLayout = ( { // If there are NO inner blocks, sync with the given template. if ( innerBlocks.length === 0 && - currentDefaultTemplate.current.length > 0 + currentDefaultTemplate.current.length > 0 && + ! templateSynced ) { const nextBlocks = createBlocksFromInnerBlocksTemplate( currentDefaultTemplate.current ); - if ( ! isEqual( nextBlocks, innerBlocks ) ) { + if ( nextBlocks.length !== 0 ) { + templateSynced = true; replaceInnerBlocks( clientId, nextBlocks ); return; } @@ -178,6 +180,6 @@ export const useForcedLayout = ( { .dispatch( 'core/block-editor' ) .insertBlocks( blockConfig, insertAtPosition, clientId ); } ); - } ); + }, 'core/block-editor' ); }, [ clientId, registry ] ); }; diff --git a/assets/js/blocks/filter-wrapper/upgrade.tsx b/assets/js/blocks/filter-wrapper/upgrade.tsx index db58d66244e..74423ede737 100644 --- a/assets/js/blocks/filter-wrapper/upgrade.tsx +++ b/assets/js/blocks/filter-wrapper/upgrade.tsx @@ -73,7 +73,7 @@ export const UpgradeNotice = ( { } ); }; - if ( isInsideFilterWrapper || ! filterType ) { + if ( isInsideFilterWrapper || ! filterType || attributes?.isPreview ) { return null; } diff --git a/assets/js/blocks/price-filter/block.json b/assets/js/blocks/price-filter/block.json index e97b1323273..bbd37bed047 100644 --- a/assets/js/blocks/price-filter/block.json +++ b/assets/js/blocks/price-filter/block.json @@ -40,6 +40,10 @@ "headingLevel": { "type": "number", "default": 3 + }, + "isPreview": { + "type": "boolean", + "default": false } }, "textdomain": "woo-gutenberg-products-block",