Skip to content

Commit

Permalink
Resize cover block only in normal mode (WordPress#65731)
Browse files Browse the repository at this point in the history
* only show resize controls in normal rendering mode

* get block editing mode from hook not prop - misread code elsewhere

Co-authored-by: draganescu <andraganescu@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
  • Loading branch information
6 people authored and huubl committed Oct 2, 2024
1 parent a9350e2 commit d0ed1ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/block-library/src/cover/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -447,7 +451,7 @@ function CoverEdit( {
<>
{ blockControls }
{ inspectorControls }
{ isSelected && (
{ hasNonContentControls && isSelected && (
<ResizableCoverPopover { ...resizableCoverProps } />
) }
<TagName
Expand Down Expand Up @@ -576,7 +580,7 @@ function CoverEdit( {
/>
<div { ...innerBlocksProps } />
</TagName>
{ isSelected && (
{ hasNonContentControls && isSelected && (
<ResizableCoverPopover { ...resizableCoverProps } />
) }
</>
Expand Down

0 comments on commit d0ed1ce

Please sign in to comment.