Skip to content

Commit

Permalink
Prevent block switcher menu while in zoom out mode (#56888)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw authored Dec 8, 2023
1 parent 6d19c32 commit 9d216e9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/block-editor/src/components/block-switcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
canRemove,
hasBlockStyles,
icon,
isZoomOutMode,
patterns,
} = useSelect(
( select ) => {
Expand All @@ -48,6 +49,7 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
canRemoveBlocks,
} = select( blockEditorStore );
const { getBlockStyles, getBlockType } = select( blocksStore );
const { __unstableGetEditorMode } = select( blockEditorStore );
const rootClientId = getBlockRootClientId(
Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds
);
Expand Down Expand Up @@ -75,6 +77,7 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
canRemove: canRemoveBlocks( clientIds, rootClientId ),
hasBlockStyles: !! styles?.length,
icon: _icon,
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
patterns: __experimentalGetPatternTransformItems(
blocks,
rootClientId
Expand Down Expand Up @@ -138,11 +141,12 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
const hasPossibleBlockVariationTransformations =
!! blockVariationTransformations?.length;
const hasPatternTransformation = !! patterns?.length && canRemove;
if (
const hasNoMenu =
! hasBlockStyles &&
! hasPossibleBlockTransformations &&
! hasPossibleBlockVariationTransformations
) {
! hasPossibleBlockVariationTransformations;

if ( hasNoMenu || isZoomOutMode ) {
return (
<ToolbarGroup>
<ToolbarButton
Expand Down

0 comments on commit 9d216e9

Please sign in to comment.