From 750640741d0539734d1b12fc75d4e2790623a8fa Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Fri, 30 May 2025 11:10:01 -0700 Subject: [PATCH] fix: Fix bug that caused children of blocks to retain passive focus when their parent is moved. --- src/actions/move.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/actions/move.ts b/src/actions/move.ts index 045a1098..da4828f6 100644 --- a/src/actions/move.ts +++ b/src/actions/move.ts @@ -12,6 +12,7 @@ import { utils, WorkspaceSvg, keyboardNavigationController, + getFocusManager, } from 'blockly'; import {Direction} from '../drag_direction'; import {Mover} from './mover'; @@ -43,6 +44,11 @@ export class MoveActions { callback: (workspace) => { keyboardNavigationController.setIsActive(true); const startBlock = this.getCurrentBlock(workspace); + // Focus the start block in case one of its fields or a shadow block + // was focused when the move was triggered. + if (startBlock) { + getFocusManager().focusNode(startBlock); + } return ( !!startBlock && this.mover.startMove(workspace, startBlock, null) ); @@ -168,6 +174,11 @@ export class MoveActions { const workspace = scope.block?.workspace as WorkspaceSvg | null; if (!workspace) return false; const startBlock = this.getCurrentBlock(workspace); + // Focus the start block in case one of its fields or a shadow block + // was focused when the move was triggered. + if (startBlock) { + getFocusManager().focusNode(startBlock); + } return ( !!startBlock && this.mover.startMove(workspace, startBlock, null) );