Skip to content

Commit

Permalink
Fix id, remove margins
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Dec 2, 2024
1 parent 588b346 commit e985024
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ export function useEventHandlers( { clientId, isSelected } ) {
const clone = node.cloneNode( true );
clone.style.visibility = 'hidden';

// Remove the id and leave it on the clone so that drop target
// calculations are correct.
const id = node.id;
node.id = null;

let _scale = 1;

let parentElement = node;
Expand Down Expand Up @@ -152,14 +157,14 @@ export function useEventHandlers( { clientId, isSelected } ) {
node.style.transformOrigin = `${ originX }px ${ originY }px`;
node.style.transition = 'transform 0.2s ease-out';
node.style.transform = `scale( 0.5 )`;
node.style.margin = '0';

let hasStarted = false;

function over( e ) {
if ( ! hasStarted ) {
hasStarted = true;
node.style.pointerEvents = 'none';
node.draggable = false;
}
node.style.top = `${ e.clientY * inverted - originY }px`;
node.style.left = `${ e.clientX * inverted - originX }px`;
Expand All @@ -177,8 +182,9 @@ export function useEventHandlers( { clientId, isSelected } ) {
node.style.left = '';
node.style.width = '';
node.style.pointerEvents = '';
node.draggable = true;
node.style.margin = '';
clone.remove();
node.id = id;
dragElement.remove();
stopDraggingBlocks();
document.body.classList.remove(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,7 @@ export default function useBlockDropZone( {
return;
}

// Don't include the dragged blocks in the block list, because
// they will have been dragged away, so the bounding client rect
// will be incorrect.
const blocks = getBlocks( targetRootClientId ).filter(
( block ) =>
! draggedBlockClientIds.includes( block.clientId )
);
const blocks = getBlocks( targetRootClientId );

// The block list is empty, don't show the insertion point but still allow dropping.
if ( blocks.length === 0 ) {
Expand Down

0 comments on commit e985024

Please sign in to comment.