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

Restrict available block actions in zoomed out mode #56886

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export function BlockSettingsDropdown( {
const firstBlockClientId = blockClientIds[ 0 ];
const {
firstParentClientId,
isZoomOutMode,
onlyBlock,
parentBlockType,
previousBlockClientId,
Expand All @@ -109,6 +110,7 @@ export function BlockSettingsDropdown( {
getPreviousBlockClientId,
getSelectedBlockClientIds,
getBlockAttributes,
__unstableGetEditorMode,
} = select( blockEditorStore );

const { getActiveBlockVariation } = select( blocksStore );
Expand All @@ -120,6 +122,7 @@ export function BlockSettingsDropdown( {

return {
firstParentClientId: _firstParentClientId,
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
onlyBlock: 1 === getBlockCount( _firstParentClientId ),
parentBlockType:
_firstParentClientId &&
Expand Down Expand Up @@ -291,7 +294,8 @@ export function BlockSettingsDropdown( {
'core/block-editor/insert-after',
event
) &&
canInsertDefaultBlock
canInsertDefaultBlock &&
! isZoomOutMode
) {
event.preventDefault();
setOpenedBlockSettingsMenu( undefined );
Expand All @@ -301,7 +305,8 @@ export function BlockSettingsDropdown( {
'core/block-editor/insert-before',
event
) &&
canInsertDefaultBlock
canInsertDefaultBlock &&
! isZoomOutMode
) {
event.preventDefault();
setOpenedBlockSettingsMenu( undefined );
Expand Down Expand Up @@ -347,7 +352,7 @@ export function BlockSettingsDropdown( {
{ __( 'Duplicate' ) }
</MenuItem>
) }
{ canInsertDefaultBlock && (
{ canInsertDefaultBlock && ! isZoomOutMode && (
<>
<MenuItem
onClick={ pipe(
Expand Down Expand Up @@ -382,25 +387,31 @@ export function BlockSettingsDropdown( {
</MenuItem>
</MenuGroup>
) }
<BlockSettingsMenuControls.Slot
fillProps={ {
onClose,
canMove,
onMoveTo,
onlyBlock,
count,
firstBlockClientId,
} }
clientIds={ clientIds }
__unstableDisplayLocation={
__unstableDisplayLocation
}
/>
{ typeof children === 'function'
? children( { onClose } )
: Children.map( ( child ) =>
cloneElement( child, { onClose } )
) }
{ ! isZoomOutMode && (
<>
<BlockSettingsMenuControls.Slot
fillProps={ {
onClose,
canMove,
onMoveTo,
onlyBlock,
count,
firstBlockClientId,
} }
clientIds={ clientIds }
__unstableDisplayLocation={
__unstableDisplayLocation
}
/>
{ typeof children === 'function'
? children( { onClose } )
: Children.map( ( child ) =>
cloneElement( child, {
onClose,
} )
) }
</>
) }
{ canRemove && (
<MenuGroup>
<MenuItem
Expand Down
Loading