From dd57be8ed39dace069a4f995463fceb3911992d9 Mon Sep 17 00:00:00 2001 From: rachel-fenichel Date: Tue, 15 Mar 2016 15:35:19 -0700 Subject: [PATCH] Don't fire events for ghost blocks. --- core/block_svg.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/block_svg.js b/core/block_svg.js index ce19f26e86..8be3558ffa 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -202,9 +202,11 @@ Blockly.BlockSvg.terminateDrag_ = function() { // Terminate a drag operation. if (selected) { if (selected.ghostBlock_) { + Blockly.Events.disable(); selected.ghostBlock_.unplug(true /* healStack */); selected.ghostBlock_.dispose(); selected.ghostBlock_ = null; + Blockly.Events.enable(); } // Update the connection locations. var xy = selected.getRelativeToSurfaceXY(); @@ -701,9 +703,12 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) { if (Blockly.highlightedConnection_ && Blockly.highlightedConnection_ != closestConnection) { if (this.ghostBlock_) { + // Don't fire events for ghost block creation or movement. + Blockly.Events.disable(); this.ghostBlock_.unplug(true /* healStack */); this.ghostBlock_.dispose(); this.ghostBlock_ = null; + Blockly.Events.enable(); } Blockly.highlightedConnection_.unhighlight(); Blockly.highlightedConnection_ = null; @@ -715,6 +720,7 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) { closestConnection.highlight(); Blockly.highlightedConnection_ = closestConnection; Blockly.localConnection_ = localConnection; + Blockly.Events.disable(); if (!this.ghostBlock_){ this.ghostBlock_ = this.workspace.newBlock(this.type); this.ghostBlock_.setGhost(true); @@ -727,6 +733,7 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) { this.ghostBlock_.previousConnection.connect(closestConnection); } this.ghostBlock_.render(true); + Blockly.Events.enable(); } // Provide visual indication of whether the block will be deleted if // dropped here.