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
Changes from 1 commit
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
45 changes: 28 additions & 17 deletions packages/block-library/src/cover/edit/block-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {
__experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl,
__experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl,
privateApis as blockEditorPrivateApis,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand Down Expand Up @@ -73,25 +75,34 @@ export default function CoverBlockControls( {
} );
};

const mode = useSelect(
( select ) => select( blockEditorStore ).__unstableGetEditorMode(),
[]
);

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>
{ 'navigation' !== mode && (
<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
Loading