From fec3423e6468857d4487d6c22cb352119240c2c8 Mon Sep 17 00:00:00 2001 From: Ella Date: Fri, 12 Apr 2024 11:38:22 +0300 Subject: [PATCH] Add comments --- packages/block-editor/src/components/iframe/index.js | 3 +++ .../src/components/block-editor/site-editor-canvas.js | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/iframe/index.js b/packages/block-editor/src/components/iframe/index.js index ca0898f6fea871..e90e8a094ba5ac 100644 --- a/packages/block-editor/src/components/iframe/index.js +++ b/packages/block-editor/src/components/iframe/index.js @@ -228,6 +228,9 @@ function Iframe( { clearerRef, writingFlowRef, disabledRef, + // Avoid resize listeners when not needed, these will trigger + // unnecessary re-renders when animating the iframe width, or when + // expanding preview iframes. scale === 1 ? null : windowResizeRef, ] ); diff --git a/packages/edit-site/src/components/block-editor/site-editor-canvas.js b/packages/edit-site/src/components/block-editor/site-editor-canvas.js index 3c6317d21327bc..94845d160ea83e 100644 --- a/packages/edit-site/src/components/block-editor/site-editor-canvas.js +++ b/packages/edit-site/src/components/block-editor/site-editor-canvas.js @@ -91,7 +91,12 @@ export default function SiteEditorCanvas( { onClick } ) { settings={ settings } onClick={ onClick } > - { enableResizing && resizeObserver } + { + // Avoid resize listeners when not needed, + // these will trigger unnecessary re-renders + // when animating the iframe width. + enableResizing && resizeObserver + }