Skip to content

Commit

Permalink
feat: fix drop zone issue in sub menu components
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayank-Tripathi32 committed Dec 25, 2024
1 parent d9b726b commit 8763709
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/block-editor/src/components/use-block-drop-zone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,24 @@ export function isDropTargetValid(

// Work out if dragged blocks have an allowed parent and if so
// check target block matches the allowed parent.
const draggedBlockTypes = draggedBlockNames.map( ( name ) =>
getBlockType( name )
);
const draggedBlockTypes = draggedBlockNames.map( ( name ) => {
const blockType = getBlockType( name );
return {
name,
parent: blockType.parent || [],
};
} );
const targetMatchesDraggedBlockParents = draggedBlockTypes.every(
( block ) => {
const [ firstParent ] = draggedBlockTypes[ 0 ]?.parent || [];
const [ allowedParentName ] = block?.parent || [];
if ( ! allowedParentName ) {
if ( ! firstParent && ! allowedParentName ) {
return true;
}

return allowedParentName === targetBlockName;
return (
firstParent === allowedParentName ||
allowedParentName === targetBlockName
);
}
);

Expand Down

0 comments on commit 8763709

Please sign in to comment.