@@ -42,6 +42,12 @@ export class Mover {
4242 */
4343 protected moves : Map < WorkspaceSvg , MoveInfo > = new Map ( ) ;
4444
45+ /**
46+ * The stashed isDragging function, which is replaced at the beginning
47+ * of a keyboard drag and reset at the end of a keyboard drag.
48+ */
49+ oldIsDragging : ( ( ) => boolean ) | null = null ;
50+
4551 constructor (
4652 protected navigation : Navigation ,
4753 protected canEdit : ( ws : WorkspaceSvg ) => boolean ,
@@ -229,6 +235,8 @@ export class Mover {
229235 // Select and focus block.
230236 common . setSelected ( block ) ;
231237 cursor . setCurNode ( ASTNode . createBlockNode ( block ) ) ;
238+
239+ this . patchIsDragging ( workspace ) ;
232240 // Begin dragging block.
233241 const DraggerClass = registry . getClassFromOptions (
234242 registry . Type . BLOCK_DRAGGER ,
@@ -262,6 +270,7 @@ export class Mover {
262270 new utils . Coordinate ( 0 , 0 ) ,
263271 ) ;
264272
273+ this . unpatchIsDragging ( workspace ) ;
265274 this . moves . delete ( workspace ) ;
266275 return true ;
267276 }
@@ -291,6 +300,7 @@ export class Mover {
291300 new utils . Coordinate ( 0 , 0 ) ,
292301 ) ;
293302
303+ this . unpatchIsDragging ( workspace ) ;
294304 this . moves . delete ( workspace ) ;
295305 return true ;
296306 }
@@ -354,6 +364,30 @@ Use enter to complete the move, or escape to abort.`);
354364 const curNode = cursor ?. getCurNode ( ) ;
355365 return ( curNode ?. getSourceBlock ( ) as BlockSvg ) ?? undefined ;
356366 }
367+
368+ /**
369+ * Monkeypatch over workspace.isDragging to return whether a keyboard
370+ * drag is in progress.
371+ *
372+ * @param workspace The workspace to patch.
373+ */
374+ private patchIsDragging ( workspace : WorkspaceSvg ) {
375+ this . oldIsDragging = workspace . isDragging ;
376+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
377+ ( workspace as any ) . isDragging = ( ) => this . isMoving ( workspace ) ;
378+ }
379+
380+ /**
381+ * Remove the monkeypatch on workspace.isDragging.
382+ *
383+ * @param workspace The workspace to unpatch.
384+ */
385+ private unpatchIsDragging ( workspace : WorkspaceSvg ) {
386+ if ( this . oldIsDragging ) {
387+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
388+ ( workspace as any ) . isDragging = this . oldIsDragging ;
389+ }
390+ }
357391}
358392
359393/**
0 commit comments