@@ -779,6 +779,61 @@ suite('Keyboard-driven movement', function () {
779779 assert . isFalse ( ifBlock . isEnabled ( ) ) ;
780780 } ) ;
781781
782+ test ( 'Cancel after committed keyboard move does not throw' , function ( ) {
783+ // if block with repeat block in next connection
784+ const json = {
785+ 'blocks' : {
786+ 'languageVersion' : 0 ,
787+ 'blocks' : [
788+ {
789+ 'type' : 'controls_if' ,
790+ 'id' : 'ifBlock' ,
791+ 'x' : 25 ,
792+ 'y' : 10 ,
793+ 'next' : {
794+ 'block' : {
795+ 'type' : 'controls_repeat_ext' ,
796+ 'id' : 'repeatBlock' ,
797+ 'inputs' : {
798+ 'TIMES' : {
799+ 'shadow' : {
800+ 'type' : 'math_number' ,
801+ 'fields' : {
802+ 'NUM' : 10 ,
803+ } ,
804+ } ,
805+ } ,
806+ } ,
807+ } ,
808+ } ,
809+ } ,
810+ ] ,
811+ } ,
812+ } ;
813+ this . workspace . clear ( ) ;
814+ Blockly . serialization . workspaces . load ( json , this . workspace ) ;
815+ const ifBlock = this . workspace . getBlockById ( 'ifBlock' ) ;
816+ const repeatBlock = this . workspace . getBlockById ( 'repeatBlock' ) ;
817+
818+ // Move the if block down twice so it connects to the repeat block statement input.
819+ Blockly . getFocusManager ( ) . focusNode ( ifBlock ) ;
820+ startMove ( this . workspace ) ;
821+ moveDown ( this . workspace ) ;
822+ moveDown ( this . workspace ) ;
823+ endMove ( this . workspace ) ;
824+
825+ assert . strictEqual ( ifBlock . getParent ( ) , repeatBlock ) ;
826+
827+ // Start a second keyboard move and cancel before committing.
828+ assert . doesNotThrow ( ( ) => {
829+ Blockly . getFocusManager ( ) . focusNode ( ifBlock ) ;
830+ startMove ( this . workspace ) ;
831+ moveUp ( this . workspace ) ;
832+ moveUp ( this . workspace ) ;
833+ cancelMove ( this . workspace ) ;
834+ } ) ;
835+ } ) ;
836+
782837 suite ( 'Statement move tests' , function ( ) {
783838 // Clear the workspace and load start blocks.
784839 setup ( function ( ) {
0 commit comments