diff --git a/core/block_svg.js b/core/block_svg.js index 8fc64f3a8..6a0df6f56 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -610,14 +610,7 @@ Blockly.BlockSvg.prototype.onMouseUp_ = function(e) { if (trashcan) { goog.Timer.callOnce(trashcan.close, 100, trashcan); } - // Save the block's workspace temporarily so we can resize the - // contents once the block is disposed. - var selectedWorkspace = Blockly.selected.workspace; Blockly.selected.dispose(false, true); - // Dropping a block on the trash can will usually cause the workspace to - // resize to contain the newly positioned block. Force a second resize - // now that the block has been deleted. - Blockly.resizeSvgContents(selectedWorkspace); } if (Blockly.highlightedConnection_) { Blockly.highlightedConnection_.unhighlight(); @@ -986,6 +979,9 @@ Blockly.BlockSvg.prototype.getSvgRoot = function() { Blockly.BlockSvg.prototype.dispose = function(healStack, animate) { Blockly.Tooltip.hide(); Blockly.Field.startCache(); + // Save the block's workspace temporarily so we can resize the + // contents once the block is disposed. + var blockWorkspace = this.workspace; // If this block is being dragged, unlink the mouse events. if (Blockly.selected == this) { this.unselect(); @@ -1012,6 +1008,7 @@ Blockly.BlockSvg.prototype.dispose = function(healStack, animate) { Blockly.BlockSvg.superClass_.dispose.call(this, healStack); goog.dom.removeNode(this.svgGroup_); + Blockly.resizeSvgContents(blockWorkspace); // Sever JavaScript to DOM connections. this.svgGroup_ = null; this.svgPath_ = null;