Skip to content

Commit 64942a1

Browse files
authored
fix: Fix bug that caused children of blocks to retain passive focus when their parent is moved. (#571)
1 parent 76388be commit 64942a1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/actions/move.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
utils,
1313
WorkspaceSvg,
1414
keyboardNavigationController,
15+
getFocusManager,
1516
} from 'blockly';
1617
import {Direction} from '../drag_direction';
1718
import {Mover} from './mover';
@@ -43,6 +44,11 @@ export class MoveActions {
4344
callback: (workspace) => {
4445
keyboardNavigationController.setIsActive(true);
4546
const startBlock = this.getCurrentBlock(workspace);
47+
// Focus the start block in case one of its fields or a shadow block
48+
// was focused when the move was triggered.
49+
if (startBlock) {
50+
getFocusManager().focusNode(startBlock);
51+
}
4652
return (
4753
!!startBlock && this.mover.startMove(workspace, startBlock, null)
4854
);
@@ -168,6 +174,11 @@ export class MoveActions {
168174
const workspace = scope.block?.workspace as WorkspaceSvg | null;
169175
if (!workspace) return false;
170176
const startBlock = this.getCurrentBlock(workspace);
177+
// Focus the start block in case one of its fields or a shadow block
178+
// was focused when the move was triggered.
179+
if (startBlock) {
180+
getFocusManager().focusNode(startBlock);
181+
}
171182
return (
172183
!!startBlock && this.mover.startMove(workspace, startBlock, null)
173184
);

0 commit comments

Comments
 (0)