Skip to content

Commit bdf5e05

Browse files
fix: just delete one block on insert abort
1 parent 2ecf843 commit bdf5e05

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/actions/mover.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,10 @@ export class Mover {
177177
info.block.getDragStrategy() as KeyboardDragStrategy;
178178
const {insertStartPoint} = keyboardDragStrategy;
179179

180-
if (insertStartPoint) {
181-
// Monkey patch dragger to trigger delete.
182-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
183-
(info.dragger as any).wouldDeleteDraggable = () => true;
184-
} else {
180+
// Monkey patch dragger to trigger delete.
181+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
182+
(info.dragger as any).wouldDeleteDraggable = () => !!insertStartPoint;
183+
if (!insertStartPoint) {
185184
// Monkey patch dragger to trigger call to draggable.revertDrag.
186185
// eslint-disable-next-line @typescript-eslint/no-explicit-any
187186
(info.dragger as any).shouldReturnToStart = () => true;
@@ -191,6 +190,10 @@ export class Mover {
191190
// Explicitly call `hidePreview` because it is not called in revertDrag.
192191
// @ts-expect-error Access to private property dragStrategy.
193192
blockSvg.dragStrategy.connectionPreviewer.hidePreview();
193+
// Prevent the stragegy connecting the block so we just delete one block.
194+
// @ts-expect-error Access to private property dragStrategy.
195+
blockSvg.dragStrategy.connectionCandidate = null;
196+
194197
info.dragger.onDragEnd(
195198
info.fakePointerEvent('pointerup'),
196199
info.startLocation,

0 commit comments

Comments
 (0)