Skip to content

Commit

Permalink
Check block groupability
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Jan 23, 2024
1 parent 2c3d92e commit e3b729f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export default function useOnBlockDrop(
getBlocksByClientId,
getSettings,
getBlock,
isGroupable,
} = useSelect( blockEditorStore );
const { getBlockType, getGroupingBlockName } = useSelect( blocksStore );
const {
Expand All @@ -253,10 +254,14 @@ export default function useOnBlockDrop(
) => {
const clientIds = getBlockOrder( targetRootClientId );
const clientId = clientIds[ targetBlockIndex ];

const blocksClientIds = blocks.map( ( block ) => block.clientId );
const areGroupableBlocks = isGroupable( [
...blocksClientIds,
clientId,
] );
if ( operation === 'replace' ) {
replaceBlocks( clientId, blocks, undefined, initialPosition );
} else if ( operation === 'group' ) {
} else if ( operation === 'group' && areGroupableBlocks ) {
const targetBlock = getBlock( clientId );
if ( nearestSide === 'left' ) {
blocks.push( targetBlock );
Expand Down

0 comments on commit e3b729f

Please sign in to comment.