Skip to content
Closed
Changes from 1 commit
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
Next Next commit
Initial experimentation with drop zones when hovering over an empty b…
…lock.
  • Loading branch information
apeatling committed Apr 20, 2022
commit a11bfa4628dba84f6aae05fd1912264526ad3d53
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,25 @@ export default function useBlockDropZone( {
// Ensure the element is a block. It should have the `wp-block` class.
( element ) => element.classList.contains( 'wp-block' )
);
const targetBlock = () => {
if ( event.srcElement.dataset?.empty === 'true' ) {
return event.target;
}

return false;
};
const targetIndex = getNearestBlockIndex(
blockElements,
{ x: event.clientX, y: event.clientY },
getBlockListSettings( targetRootClientId )?.orientation
);

setTargetBlockIndex( targetIndex === undefined ? 0 : targetIndex );
if ( ! targetBlock() ) {
setTargetBlockIndex( targetIndex === undefined ? 0 : targetIndex );

if ( targetIndex !== null ) {
showInsertionPoint( targetRootClientId, targetIndex );
if ( targetIndex !== null ) {
showInsertionPoint( targetRootClientId, targetIndex );
}
}
}, [] ),
200
Expand Down