File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -1057,11 +1057,14 @@ export class Navigation {
10571057 if ( ! cursor ) {
10581058 return ;
10591059 }
1060- const curNode = cursor . getCurNode ( ) ;
1061- if ( ! curNode . isConnection ( ) ) {
1062- this . log (
1063- 'Cannot disconnect blocks when the cursor is not on a connection' ,
1064- ) ;
1060+ let curNode : Blockly . ASTNode | null = cursor . getCurNode ( ) ;
1061+ let wasVisitingConnection = true ;
1062+ while ( curNode && ! curNode . isConnection ( ) ) {
1063+ curNode = curNode . out ( ) ;
1064+ wasVisitingConnection = false ;
1065+ }
1066+ if ( ! curNode ) {
1067+ this . log ( 'Unable to find a connection to disconnect' ) ;
10651068 return ;
10661069 }
10671070 const curConnection = curNode . getLocation ( ) as Blockly . RenderedConnection ;
@@ -1087,9 +1090,11 @@ export class Navigation {
10871090 const rootBlock = superiorConnection . getSourceBlock ( ) . getRootBlock ( ) ;
10881091 rootBlock . bringToFront ( ) ;
10891092
1090- const connectionNode =
1091- Blockly . ASTNode . createConnectionNode ( superiorConnection ) ;
1092- workspace . getCursor ( ) ! . setCurNode ( connectionNode ! ) ;
1093+ if ( wasVisitingConnection ) {
1094+ const connectionNode =
1095+ Blockly . ASTNode . createConnectionNode ( superiorConnection ) ;
1096+ workspace . getCursor ( ) ! . setCurNode ( connectionNode ! ) ;
1097+ }
10931098 }
10941099
10951100 /**
You can’t perform that action at this time.
0 commit comments