diff --git a/packages/block-editor/src/components/iframe/content.scss b/packages/block-editor/src/components/iframe/content.scss index 596c177eab2f32..fc5190698c409e 100644 --- a/packages/block-editor/src/components/iframe/content.scss +++ b/packages/block-editor/src/components/iframe/content.scss @@ -20,7 +20,6 @@ .block-editor-iframe__html.is-zoomed-out { $scale: var(--wp-block-editor-iframe-zoom-out-scale); $frame-size: var(--wp-block-editor-iframe-zoom-out-frame-size); - $inner-height: var(--wp-block-editor-iframe-zoom-out-inner-height); $content-height: var(--wp-block-editor-iframe-zoom-out-content-height); $scale-container-width: var(--wp-block-editor-iframe-zoom-out-scale-container-width); $container-width: var(--wp-block-editor-iframe-zoom-out-container-width, 100vw); @@ -42,17 +41,6 @@ padding-bottom: calc(#{$frame-size} / #{$scale}); body { - min-height: calc((#{$inner-height} - #{$total-frame-height}) / #{$scale}); - - > .is-root-container:not(.wp-block-post-content) { - flex: 1; - display: flex; - flex-direction: column; - height: 100%; - - > main { - flex: 1; - } - } + min-height: 100vh; } } diff --git a/packages/block-editor/src/components/iframe/index.js b/packages/block-editor/src/components/iframe/index.js index 85e1f12a7c0d63..15f61c43dc8ec0 100644 --- a/packages/block-editor/src/components/iframe/index.js +++ b/packages/block-editor/src/components/iframe/index.js @@ -209,21 +209,6 @@ function Iframe( { }; }, [] ); - const [ iframeWindowInnerHeight, setIframeWindowInnerHeight ] = useState(); - - const iframeResizeRef = useRefEffect( ( node ) => { - const nodeWindow = node.ownerDocument.defaultView; - - setIframeWindowInnerHeight( nodeWindow.innerHeight ); - const onResize = () => { - setIframeWindowInnerHeight( nodeWindow.innerHeight ); - }; - nodeWindow.addEventListener( 'resize', onResize ); - return () => { - nodeWindow.removeEventListener( 'resize', onResize ); - }; - }, [] ); - const [ windowInnerWidth, setWindowInnerWidth ] = useState(); const windowResizeRef = useRefEffect( ( node ) => { @@ -259,10 +244,6 @@ 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. - isZoomedOut ? iframeResizeRef : null, ] ); // Correct doctype is required to enable rendering in standards @@ -370,10 +351,6 @@ function Iframe( { '--wp-block-editor-iframe-zoom-out-content-height', `${ contentHeight }px` ); - iframeDocument.documentElement.style.setProperty( - '--wp-block-editor-iframe-zoom-out-inner-height', - `${ iframeWindowInnerHeight }px` - ); iframeDocument.documentElement.style.setProperty( '--wp-block-editor-iframe-zoom-out-container-width', `${ containerWidth }px` @@ -393,9 +370,6 @@ function Iframe( { iframeDocument.documentElement.style.removeProperty( '--wp-block-editor-iframe-zoom-out-content-height' ); - iframeDocument.documentElement.style.removeProperty( - '--wp-block-editor-iframe-zoom-out-inner-height' - ); iframeDocument.documentElement.style.removeProperty( '--wp-block-editor-iframe-zoom-out-container-width' ); @@ -407,7 +381,6 @@ function Iframe( { scale, frameSize, iframeDocument, - iframeWindowInnerHeight, contentHeight, containerWidth, windowInnerWidth, diff --git a/packages/editor/src/components/visual-editor/index.js b/packages/editor/src/components/visual-editor/index.js index 1c8eb5c3b77640..e6a326832e5e86 100644 --- a/packages/editor/src/components/visual-editor/index.js +++ b/packages/editor/src/components/visual-editor/index.js @@ -119,6 +119,7 @@ function VisualEditor( { isDesignPostType, postType, isPreview, + isEditedPostEmpty, } = useSelect( ( select ) => { const { getCurrentPostId, @@ -127,6 +128,7 @@ function VisualEditor( { getEditorSettings, getRenderingMode, getDeviceType, + isEditedPostEmpty: getIsEditedPostEmpty, } = select( editorStore ); const { getPostType, getEditedEntityRecord } = select( coreStore ); const postTypeSlug = getCurrentPostType(); @@ -167,6 +169,7 @@ function VisualEditor( { isFocusedEntity: !! editorSettings.onNavigateToPreviousEntityRecord, postType: postTypeSlug, isPreview: editorSettings.isPreviewMode, + isEditedPostEmpty: getIsEditedPostEmpty(), }; }, [] ); const { isCleanNewPost } = useSelect( editorStore ); @@ -363,10 +366,15 @@ function VisualEditor( { // Some themes will have `min-height: 100vh` for the root container, // which isn't a requirement in auto resize mode. enableResizing ? 'min-height:0!important;' : '' - }}`, + }}${ + // Vertically expands the top-level post content block when zoomed out on an empty post. + isEditedPostEmpty && isZoomedOut + ? '.entry-content {min-height: 33vh;}' + : '' + }`, }, ]; - }, [ styles, enableResizing ] ); + }, [ styles, enableResizing, isEditedPostEmpty, isZoomedOut ] ); return (