From 2523da53320c770564af8336ae610832012fcca8 Mon Sep 17 00:00:00 2001 From: alschmiedt Date: Thu, 17 Sep 2020 16:45:24 -0700 Subject: [PATCH] Fixes blocks flying when mutator is open (#4289) --- core/mutator.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/mutator.js b/core/mutator.js index 462a78b04..3e4ba64cc 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -401,15 +401,28 @@ Blockly.Mutator.prototype.workspaceChanged_ = function(e) { var block = this.block_; var oldMutationDom = block.mutationToDom(); var oldMutation = oldMutationDom && Blockly.Xml.domToText(oldMutationDom); + + // Switch off rendering while the source block is rebuilt. + var savedRendered = block.rendered; + // TODO(#4288): We should not be setting the rendered property to false. + block.rendered = false; + // Allow the source block to rebuild itself. block.compose(this.rootBlock_); + // Restore rendering and show the changes. + block.rendered = savedRendered; + // Mutation may have added some elements that need initializing. block.initSvg(); - block.render(); if ((/** @type {!Blockly.WorkspaceSvg} */ (Blockly.getMainWorkspace())) .keyboardAccessibilityMode) { Blockly.navigation.moveCursorOnBlockMutation(block); } + + if (block.rendered) { + block.render(); + } + var newMutationDom = block.mutationToDom(); var newMutation = newMutationDom && Blockly.Xml.domToText(newMutationDom); if (oldMutation != newMutation) {