Wrap typeblock updates in an event group
@@ -492,8 +492,7 @@ Blockly.TypeBlock.prototype.createAutoComplete_ = function(inputText){
value: blockName
}
};
- }
- else if (textMatch && textMatch.length === 1){
+ } else if (textMatch && textMatch.length === 1) {
blockToCreate = {
canonicName: 'text',
dropDown: {
@@ -501,13 +500,15 @@ Blockly.TypeBlock.prototype.createAutoComplete_ = function(inputText){
value: blockName.substring(1)
}
};
- }
- else
+ } else {
return; // block does not exist: return
}
+ }
var blockToCreateName = '';
var block;
+ Blockly.Events.setGroup(true);
+ try {
if (blockToCreate.dropDown) { //All blocks should have a dropDown property, even if empty
blockToCreateName = blockToCreate.canonicName;
// components have mutator attributes we need to deal with. We can also add these for special blocks
@@ -558,8 +559,7 @@ Blockly.TypeBlock.prototype.createAutoComplete_ = function(inputText){
Blockly.selected.getRelativeToSurfaceXY().y + 50);
}
block.select();
- }
- else {
+ } else {
//calculate positions relative to the view and the latest click
var left = self.workspace_.latestClick.x;
var top = self.workspace_.latestClick.y;
@@ -569,6 +569,9 @@ Blockly.TypeBlock.prototype.createAutoComplete_ = function(inputText){
self.workspace_.requestErrorChecking(block);
self.hide();
self.workspace_.getParentSvg().parentNode.focus(); // refocus workspace div
+ } finally {
+ Blockly.Events.setGroup(false);
+ }
}
);
};
@@ -603,6 +606,7 @@ Blockly.TypeBlock.prototype.connectIfPossible = function(blockSelected, createdB
// Only attempt a connection if the input is empty
else if (!inputList[i].connection.isConnected()) {
createdBlock.previousConnection.connect(inputList[i].connection);
+ break;
}
} catch(e) {
//We can ignore these exceptions; they happen when connecting two blocks
