Skip to content

Commit

Permalink
Grid: Prevent highlight of cells when dragging a block if block type …
Browse files Browse the repository at this point in the history
…can't be dropped into grid (WordPress#64290)

Co-authored-by: talldan <[email protected]>
Co-authored-by: noisysocks <[email protected]>
Co-authored-by: hanneslsm <[email protected]>
  • Loading branch information
4 people authored Aug 9, 2024
1 parent b6da9e0 commit 00d28d0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/block-editor/src/components/grid/grid-visualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,12 @@ function useGridVisualizerDropZone(
gridInfo,
setHighlightedRect
) {
const { getBlockAttributes, getBlockRootClientId } =
useSelect( blockEditorStore );
const {
getBlockAttributes,
getBlockRootClientId,
canInsertBlockType,
getBlockName,
} = useSelect( blockEditorStore );
const {
updateBlockAttributes,
moveBlocksToPosition,
Expand All @@ -221,6 +225,10 @@ function useGridVisualizerDropZone(

return useDropZoneWithValidation( {
validateDrag( srcClientId ) {
const blockName = getBlockName( srcClientId );
if ( ! canInsertBlockType( blockName, gridClientId ) ) {
return false;
}
const attributes = getBlockAttributes( srcClientId );
const rect = new GridRect( {
columnStart: column,
Expand Down

0 comments on commit 00d28d0

Please sign in to comment.