From d0ed1cef443ae2cb351ab017ba208febcaf90f30 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Wed, 2 Oct 2024 09:45:01 +0300 Subject: [PATCH] Resize cover block only in normal mode (#65731) * only show resize controls in normal rendering mode * get block editing mode from hook not prop - misread code elsewhere Co-authored-by: draganescu Co-authored-by: getdave Co-authored-by: MaggieCabrera Co-authored-by: scruffian Co-authored-by: ellatrix --- packages/block-library/src/cover/edit/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/cover/edit/index.js b/packages/block-library/src/cover/edit/index.js index ec62bd58a2c33a..804027708881b6 100644 --- a/packages/block-library/src/cover/edit/index.js +++ b/packages/block-library/src/cover/edit/index.js @@ -18,6 +18,7 @@ import { useInnerBlocksProps, __experimentalUseGradient, store as blockEditorStore, + useBlockEditingMode, } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { useSelect, useDispatch } from '@wordpress/data'; @@ -278,6 +279,9 @@ function CoverEdit( { const isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType; const isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType; + const blockEditingMode = useBlockEditingMode(); + const hasNonContentControls = blockEditingMode === 'default'; + const [ resizeListener, { height, width } ] = useResizeObserver(); const resizableBoxDimensions = useMemo( () => { return { @@ -447,7 +451,7 @@ function CoverEdit( { <> { blockControls } { inspectorControls } - { isSelected && ( + { hasNonContentControls && isSelected && ( ) }
- { isSelected && ( + { hasNonContentControls && isSelected && ( ) }