From da79a120f2c21512b768515083b50ffba69078d7 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 28 Mar 2024 22:39:48 +0000 Subject: [PATCH] fix: remove parameter from wouldDelete (#7968) --- core/block_dragger.ts | 15 +++------------ core/bubble_dragger.ts | 2 +- core/config.ts | 2 -- core/delete_area.ts | 5 ++--- core/dragging/dragger.ts | 6 +----- core/insertion_marker_manager.ts | 5 +---- core/interfaces/i_delete_area.ts | 3 +-- core/toolbox/toolbox.ts | 4 +--- 8 files changed, 10 insertions(+), 32 deletions(-) diff --git a/core/block_dragger.ts b/core/block_dragger.ts index 596f27f83..96c0bbf5f 100644 --- a/core/block_dragger.ts +++ b/core/block_dragger.ts @@ -205,7 +205,7 @@ export class BlockDragger implements IBlockDragger { const block = this.draggingBlock_; this.moveBlock(block, delta); this.updateDragTargets(e, block); - this.wouldDeleteBlock_ = this.wouldDeleteBlock(e, block, delta); + this.wouldDeleteBlock_ = this.wouldDeleteBlock(e, block); this.updateCursorDuringBlockDrag_(); this.updateConnectionPreview(block, delta); } @@ -237,14 +237,8 @@ export class BlockDragger implements IBlockDragger { * * @param e The most recent move event. * @param draggingBlock The block being dragged. - * @param delta How far the pointer has moved from the position - * at the start of the drag, in pixel units. */ - private wouldDeleteBlock( - e: PointerEvent, - draggingBlock: BlockSvg, - delta: Coordinate, - ): boolean { + private wouldDeleteBlock(e: PointerEvent, draggingBlock: BlockSvg): boolean { const dragTarget = this.workspace_.getDragTarget(e); if (!dragTarget) return false; @@ -255,10 +249,7 @@ export class BlockDragger implements IBlockDragger { ); if (!isDeleteArea) return false; - return (dragTarget as IDeleteArea).wouldDelete( - draggingBlock, - !!this.getConnectionCandidate(draggingBlock, delta), - ); + return (dragTarget as IDeleteArea).wouldDelete(draggingBlock); } /** diff --git a/core/bubble_dragger.ts b/core/bubble_dragger.ts index e494c7ad2..d3820e4c5 100644 --- a/core/bubble_dragger.ts +++ b/core/bubble_dragger.ts @@ -116,7 +116,7 @@ export class BubbleDragger { ComponentManager.Capability.DELETE_AREA, ); if (isDeleteArea) { - return (dragTarget as IDeleteArea).wouldDelete(this.bubble, false); + return (dragTarget as IDeleteArea).wouldDelete(this.bubble); } } return false; diff --git a/core/config.ts b/core/config.ts index a6642c266..9def1dca4 100644 --- a/core/config.ts +++ b/core/config.ts @@ -47,8 +47,6 @@ export const config: Config = { /** * Maximum misalignment between connections for them to snap together. * This should be the same as the snap radius. - * - * @deprecated v11 - This is no longer used. Use snapRadius instead. */ connectingSnapRadius: DEFAULT_SNAP_RADIUS, /** diff --git a/core/delete_area.ts b/core/delete_area.ts index 1327ce6e3..6d30a434c 100644 --- a/core/delete_area.ts +++ b/core/delete_area.ts @@ -51,15 +51,14 @@ export class DeleteArea extends DragTarget implements IDeleteArea { * before onDragEnter/onDragOver/onDragExit. * * @param element The block or bubble currently being dragged. - * @param couldConnect Whether the element could could connect to another. * @returns Whether the element provided would be deleted if dropped on this * area. */ - wouldDelete(element: IDraggable, couldConnect: boolean): boolean { + wouldDelete(element: IDraggable): boolean { if (element instanceof BlockSvg) { const block = element; const couldDeleteBlock = !block.getParent() && block.isDeletable(); - this.updateWouldDelete_(couldDeleteBlock && !couldConnect); + this.updateWouldDelete_(couldDeleteBlock); } else { this.updateWouldDelete_(element.isDeletable()); } diff --git a/core/dragging/dragger.ts b/core/dragging/dragger.ts index 734adeeb9..d435e02bb 100644 --- a/core/dragging/dragger.ts +++ b/core/dragging/dragger.ts @@ -88,11 +88,7 @@ export class Dragger implements IDragger { ); if (!isDeleteArea) return false; - return (dragTarget as IDeleteArea).wouldDelete( - draggable, - false, - // !!this.getConnectionCandidate(draggable, delta), - ); + return (dragTarget as IDeleteArea).wouldDelete(draggable); } /** Handles any drag cleanup. */ diff --git a/core/insertion_marker_manager.ts b/core/insertion_marker_manager.ts index ff0f3389d..376297f10 100644 --- a/core/insertion_marker_manager.ts +++ b/core/insertion_marker_manager.ts @@ -384,10 +384,7 @@ export class InsertionMarkerManager { ComponentManager.Capability.DELETE_AREA, ); if (isDeleteArea) { - return (dragTarget as IDeleteArea).wouldDelete( - this.topBlock, - newCandidate, - ); + return (dragTarget as IDeleteArea).wouldDelete(this.topBlock); } } return false; diff --git a/core/interfaces/i_delete_area.ts b/core/interfaces/i_delete_area.ts index a6e5d9e05..6d4a6631d 100644 --- a/core/interfaces/i_delete_area.ts +++ b/core/interfaces/i_delete_area.ts @@ -21,9 +21,8 @@ export interface IDeleteArea extends IDragTarget { * before onDragEnter/onDragOver/onDragExit. * * @param element The block or bubble currently being dragged. - * @param couldConnect Whether the element could could connect to another. * @returns Whether the element provided would be deleted if dropped on this * area. */ - wouldDelete(element: IDraggable, couldConnect: boolean): boolean; + wouldDelete(element: IDraggable): boolean; } diff --git a/core/toolbox/toolbox.ts b/core/toolbox/toolbox.ts index a989f5977..e49d0b9c4 100644 --- a/core/toolbox/toolbox.ts +++ b/core/toolbox/toolbox.ts @@ -532,14 +532,12 @@ export class Toolbox * before onDragEnter/onDragOver/onDragExit. * * @param element The block or bubble currently being dragged. - * @param _couldConnect Whether the element could could connect to another. * @returns Whether the element provided would be deleted if dropped on this * area. */ - override wouldDelete(element: IDraggable, _couldConnect: boolean): boolean { + override wouldDelete(element: IDraggable): boolean { if (element instanceof BlockSvg) { const block = element; - // Prefer dragging to the toolbox over connecting to other blocks. this.updateWouldDelete_(!block.getParent() && block.isDeletable()); } else { this.updateWouldDelete_(element.isDeletable());