diff --git a/core/block_svg.js b/core/block_svg.js index cfae29027..af19bb4a1 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -1413,7 +1413,12 @@ Blockly.BlockSvg.prototype.addSelect = function() { Blockly.addClass_(/** @type {!Element} */ (this.svgGroup_), 'blocklySelected'); // Move the selected block to the top of the stack. - this.svgGroup_.parentNode.appendChild(this.svgGroup_); + var block = this; + do { + var root = block.getSvgRoot(); + root.parentNode.appendChild(root); + block = block.getParent(); + } while (block); }; /**