From fffc19365c047d28ef60261ca661da2ffedebfd0 Mon Sep 17 00:00:00 2001 From: madhusudhand Date: Thu, 2 Feb 2023 20:08:39 +0530 Subject: [PATCH] fix inline preview infinite render --- .../global-styles/block-preview-panel.js | 20 ++++++++----------- .../src/components/global-styles/style.scss | 4 ---- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/block-preview-panel.js b/packages/edit-site/src/components/global-styles/block-preview-panel.js index f41181a23d2958..9ff5a47f77f088 100644 --- a/packages/edit-site/src/components/global-styles/block-preview-panel.js +++ b/packages/edit-site/src/components/global-styles/block-preview-panel.js @@ -3,14 +3,9 @@ */ import { BlockPreview } from '@wordpress/block-editor'; import { getBlockType, getBlockFromExample } from '@wordpress/blocks'; -import { useResizeObserver } from '@wordpress/compose'; import { __experimentalSpacer as Spacer } from '@wordpress/components'; const BlockPreviewPanel = ( { name, variation = '' } ) => { - const [ - containerResizeListener, - { width: containerWidth, height: containerHeight }, - ] = useResizeObserver(); const blockExample = getBlockType( name )?.example; const blockExampleWithVariation = { ...blockExample, @@ -25,23 +20,24 @@ const BlockPreviewPanel = ( { name, variation = '' } ) => { name, variation ? blockExampleWithVariation : blockExample ); - const viewportWidth = blockExample?.viewportWidth || containerWidth; - const minHeight = containerHeight; + const viewportWidth = blockExample?.viewportWidth || null; + const previewHeight = '150px'; return ! blockExample ? null : ( -
- { containerResizeListener } - +