Skip to content

Commit f13124f

Browse files
committed
refactor: Move drag indicator addition/removal into KeyboardDragStrategy.
1 parent c6432d5 commit f13124f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/actions/mover.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import * as Constants from '../constants';
1717
import {Direction, getXYFromDirection} from '../drag_direction';
1818
import {KeyboardDragStrategy} from '../keyboard_drag_strategy';
1919
import {Navigation} from '../navigation';
20-
import {MoveIcon} from '../move_icon';
2120
import {clearMoveHints} from '../hints';
2221

2322
/**
@@ -124,7 +123,6 @@ export class Mover {
124123
// Begin drag.
125124
dragger.onDragStart(info.fakePointerEvent('pointerdown'));
126125
info.updateTotalDelta();
127-
block.addIcon(new MoveIcon(block));
128126
return true;
129127
}
130128

@@ -147,8 +145,6 @@ export class Mover {
147145
new utils.Coordinate(0, 0),
148146
);
149147

150-
info.block.removeIcon(MoveIcon.type);
151-
152148
this.unpatchWorkspace(workspace);
153149
this.unpatchDragStrategy(info.block);
154150
this.moves.delete(workspace);
@@ -176,8 +172,6 @@ export class Mover {
176172
(info.dragger as any).shouldReturnToStart = () => true;
177173
const blockSvg = info.block;
178174

179-
blockSvg.removeIcon(MoveIcon.type);
180-
181175
// Explicitly call `hidePreview` because it is not called in revertDrag.
182176
// @ts-expect-error Access to private property dragStrategy.
183177
blockSvg.dragStrategy.connectionPreviewer.hidePreview();

src/keyboard_drag_strategy.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from 'blockly';
1515
import {Direction, getDirectionFromXY} from './drag_direction';
1616
import {showUnconstrainedMoveHint} from './hints';
17+
import {MoveIcon} from './move_icon';
1718

1819
// Copied in from core because it is not exported.
1920
interface ConnectionCandidate {
@@ -44,6 +45,8 @@ export class KeyboardDragStrategy extends dragging.BlockDragStrategy {
4445
// @ts-expect-error connectionCandidate is private.
4546
this.connectionCandidate = this.createInitialCandidate();
4647
this.forceShowPreview();
48+
// @ts-expect-error block is private.
49+
this.block.addIcon(new MoveIcon(this.block));
4750
}
4851

4952
override drag(newLoc: utils.Coordinate, e?: PointerEvent): void {
@@ -80,6 +83,12 @@ export class KeyboardDragStrategy extends dragging.BlockDragStrategy {
8083
}
8184
}
8285

86+
override endDrag(e?: PointerEvent) {
87+
super.endDrag(e);
88+
// @ts-expect-error block is private.
89+
this.block.removeIcon(MoveIcon.type);
90+
}
91+
8392
/**
8493
* Returns the next compatible connection in keyboard navigation order,
8594
* based on the input direction.

0 commit comments

Comments
 (0)