From 0607cf63a22671165a9106d609837120904dcfa3 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 6 Feb 2024 08:21:20 +0400 Subject: [PATCH] useOnBlockDrop: Fix the Gallery block check --- .../src/components/use-on-block-drop/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/components/use-on-block-drop/index.js b/packages/block-editor/src/components/use-on-block-drop/index.js index 212afd7aa96ee5..58ce615436d8eb 100644 --- a/packages/block-editor/src/components/use-on-block-drop/index.js +++ b/packages/block-editor/src/components/use-on-block-drop/index.js @@ -234,7 +234,7 @@ export default function useOnBlockDrop( getBlock, isGroupable, } = useSelect( blockEditorStore ); - const { getBlockType, getGroupingBlockName } = useSelect( blocksStore ); + const { getGroupingBlockName } = useSelect( blocksStore ); const { insertBlocks, moveBlocksToPosition, @@ -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 @@ -292,7 +295,8 @@ export default function useOnBlockDrop( { layout: { type: 'flex', - flexWrap: areAllImages ? null : 'nowrap', + flexWrap: + areAllImages && galleryBlock ? null : 'nowrap', }, }, groupInnerBlocks @@ -319,11 +323,12 @@ export default function useOnBlockDrop( getBlockOrder, targetRootClientId, targetBlockIndex, + isGroupable, operation, replaceBlocks, getBlock, nearestSide, - getBlockType, + canInsertBlockType, getGroupingBlockName, insertBlocks, ]