Skip to content

Commit

Permalink
useOnBlockDrop: Fix the Gallery block check
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Feb 6, 2024
1 parent 8afe850 commit 0607cf6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/block-editor/src/components/use-on-block-drop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export default function useOnBlockDrop(
getBlock,
isGroupable,
} = useSelect( blockEditorStore );
const { getBlockType, getGroupingBlockName } = useSelect( blocksStore );
const { getGroupingBlockName } = useSelect( blocksStore );
const {
insertBlocks,
moveBlocksToPosition,
Expand Down Expand Up @@ -283,7 +283,10 @@ export default function useOnBlockDrop(
return block.name === 'core/image';
} );

const galleryBlock = !! getBlockType( 'core/gallery' );
const galleryBlock = canInsertBlockType(
'core/gallery',
targetRootClientId
);

const wrappedBlocks = createBlock(
areAllImages && galleryBlock
Expand All @@ -292,7 +295,8 @@ export default function useOnBlockDrop(
{
layout: {
type: 'flex',
flexWrap: areAllImages ? null : 'nowrap',
flexWrap:
areAllImages && galleryBlock ? null : 'nowrap',
},
},
groupInnerBlocks
Expand All @@ -319,11 +323,12 @@ export default function useOnBlockDrop(
getBlockOrder,
targetRootClientId,
targetBlockIndex,
isGroupable,
operation,
replaceBlocks,
getBlock,
nearestSide,
getBlockType,
canInsertBlockType,
getGroupingBlockName,
insertBlocks,
]
Expand Down

0 comments on commit 0607cf6

Please sign in to comment.