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 {
1057
1057
if ( ! cursor ) {
1058
1058
return ;
1059
1059
}
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' ) ;
1065
1068
return ;
1066
1069
}
1067
1070
const curConnection = curNode . getLocation ( ) as Blockly . RenderedConnection ;
@@ -1087,9 +1090,11 @@ export class Navigation {
1087
1090
const rootBlock = superiorConnection . getSourceBlock ( ) . getRootBlock ( ) ;
1088
1091
rootBlock . bringToFront ( ) ;
1089
1092
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
+ }
1093
1098
}
1094
1099
1095
1100
/**
You can’t perform that action at this time.
0 commit comments