Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit "design" controls from Cover block toolbar while in Write mode #66853

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions packages/block-library/src/cover/edit/block-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function CoverBlockControls( {
currentSettings,
toggleUseFeaturedImage,
onClearMedia,
blockEditingMode,
} ) {
const { contentPosition, id, useFeaturedImage, minHeight, minHeightUnit } =
attributes;
Expand Down Expand Up @@ -73,25 +74,32 @@ export default function CoverBlockControls( {
} );
};

const hasNonContentControls = blockEditingMode === 'default';
const isContentOnlyMode = blockEditingMode === 'contentOnly';

return (
<>
<BlockControls group="block">
<BlockAlignmentMatrixControl
label={ __( 'Change content position' ) }
value={ contentPosition }
onChange={ ( nextPosition ) =>
setAttributes( {
contentPosition: nextPosition,
} )
}
isDisabled={ ! hasInnerBlocks }
/>
<FullHeightAlignmentControl
isActive={ isMinFullHeight }
onToggle={ toggleMinFullHeight }
isDisabled={ ! hasInnerBlocks }
/>
</BlockControls>
{ ! isContentOnlyMode && hasNonContentControls && (
<BlockControls group="block">
<>
<BlockAlignmentMatrixControl
label={ __( 'Change content position' ) }
value={ contentPosition }
onChange={ ( nextPosition ) =>
setAttributes( {
contentPosition: nextPosition,
} )
}
isDisabled={ ! hasInnerBlocks }
/>
<FullHeightAlignmentControl
isActive={ isMinFullHeight }
onToggle={ toggleMinFullHeight }
isDisabled={ ! hasInnerBlocks }
/>
</>
</BlockControls>
) }
<BlockControls group="other">
<MediaReplaceFlow
mediaId={ id }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/cover/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ function CoverEdit( {
currentSettings={ currentSettings }
toggleUseFeaturedImage={ toggleUseFeaturedImage }
onClearMedia={ onClearMedia }
blockEditingMode={ blockEditingMode }
/>
);

Expand Down
Loading