Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow dropping outside section root in Zoom Out mode #64500

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -313,6 +313,8 @@ export default function useBlockDropZone( {
getAllowedBlocks,
isDragging,
isGroupable,
getSettings,
isZoomOutMode,
} = unlock( useSelect( blockEditorStore ) );
const {
showInsertionPoint,
@@ -343,6 +345,7 @@ export default function useBlockDropZone( {
const targetBlockName = getBlockNamesByClientId( [
targetRootClientId,
] )[ 0 ];

const draggedBlockNames = getBlockNamesByClientId(
getDraggedBlockClientIds()
);
@@ -352,10 +355,23 @@ export default function useBlockDropZone( {
draggedBlockNames,
targetBlockName
);

if ( ! isBlockDroppingAllowed ) {
return;
}

const { sectionRootClientId } = unlock( getSettings() );

// In Zoom Out mode, if the target is not the section root provided by settings then
// do not allow dropping as the drop target is not within the root (that which is
// treated as "the content" by Zoom Out Mode).
if (
isZoomOutMode() &&
sectionRootClientId !== targetRootClientId
) {
return;
}

const blocks = getBlocks( targetRootClientId );

// The block list is empty, don't show the insertion point but still allow dropping.
@@ -470,6 +486,7 @@ export default function useBlockDropZone( {
} );
},
[
isDragging,
getAllowedBlocks,
targetRootClientId,
getBlockNamesByClientId,
@@ -481,13 +498,14 @@ export default function useBlockDropZone( {
parentBlockClientId,
getBlockIndex,
registry,
showInsertionPoint,
isDragging,
startDragging,
showInsertionPoint,
canInsertBlockType,
isGroupable,
getBlockVariations,
getGroupingBlockName,
isGroupable,
getSettings,
isZoomOutMode,
]
),
200
Loading