mirror of
https://github.com/google/blockly.git
synced 2026-01-11 02:47:09 +01:00
Fixes not being able to move block with parent (#2920)
* Fixes not being able to move block with parent
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user