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

fix!: remove couldConnect parameter from wouldDelete #7968

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 3 additions & 12 deletions core/block_dragger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;

Expand All @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/bubble_dragger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
/**
Expand Down
5 changes: 2 additions & 3 deletions core/delete_area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
6 changes: 1 addition & 5 deletions core/dragging/dragger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
5 changes: 1 addition & 4 deletions core/insertion_marker_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions core/interfaces/i_delete_area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 1 addition & 3 deletions core/toolbox/toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading