Fixes not being able to move block with parent (#2920)

* Fixes not being able to move block with parent
This commit is contained in:
alschmiedt
2019-08-27 10:12:49 -07:00
committed by GitHub
parent dc1e7b82fe
commit d8b431ae61
2 changed files with 15 additions and 5 deletions

View File

@@ -486,9 +486,9 @@ Blockly.navigation.modify = function() {
/**
* If the two blocks are compatible move the moving connection to the target
* connection and connect them.
* @param {Blockly.Connection} movingConnection The connection that is being
* @param {!Blockly.Connection} movingConnection The connection that is being
* moved.
* @param {Blockly.Connection} destConnection The connection to be moved to.
* @param {!Blockly.Connection} destConnection The connection to be moved to.
* @return {boolean} True if the connections were connected, false otherwise.
* @private
*/
@@ -497,9 +497,9 @@ Blockly.navigation.moveAndConnect_ = function(movingConnection, destConnection)
if (destConnection.canConnectWithReason_(movingConnection) ==
Blockly.Connection.CAN_CONNECT) {
if (destConnection.type == Blockly.PREVIOUS_STATEMENT ||
destConnection.type == Blockly.OUTPUT_VALUE) {
movingBlock.positionNearConnection(movingConnection, destConnection);
if (!destConnection.isSuperior()) {
var rootBlock = movingBlock.getRootBlock();
rootBlock.positionNearConnection(movingConnection, destConnection);
}
destConnection.connect(movingConnection);
return true;

View File

@@ -507,6 +507,16 @@ suite('Navigation', function() {
chai.assert.equal(this.basicBlock.nextConnection.targetBlock(), this.basicBlock4);
chai.assert.equal(this.basicBlock3.nextConnection.targetConnection, null);
});
test('Connect cursor with parents', function() {
var markedLocation = this.basicBlock3.previousConnection;
var cursorLocation = this.basicBlock2.nextConnection;
Blockly.navigation.connect(cursorLocation, markedLocation);
chai.assert.equal(this.basicBlock3.previousConnection.targetBlock(), this.basicBlock2);
});
});