From bacfae24dd75720e7c2fea547a020650be56b461 Mon Sep 17 00:00:00 2001 From: Erik Pasternak Date: Thu, 18 Jul 2019 14:08:53 -0700 Subject: [PATCH] Properly set the display style on blocks when connections are unhidden We weren't always setting the display style on blocks when the hidden state changed on a connection. This meant that sometimes unhiding a connection would cause the attached block to be invisible. This moves the display style code into the setHidden so it is never skipped. --- core/rendered_connection.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/rendered_connection.js b/core/rendered_connection.js index 6dba66123..9d6739b29 100644 --- a/core/rendered_connection.js +++ b/core/rendered_connection.js @@ -283,6 +283,12 @@ Blockly.RenderedConnection.prototype.setHidden = function(hidden) { } else if (!hidden && !this.inDB_) { this.db_.addConnection(this); } + if (this.isSuperior() && this.targetBlock()) { + var display = hidden ? 'none' : 'block'; + var renderedBlock = this.targetBlock(); + renderedBlock.getSvgRoot().style.display = display; + renderedBlock.rendered = !hidden; + } }; /** @@ -344,11 +350,6 @@ Blockly.RenderedConnection.prototype.connect = function(otherConnection) { } else { superiorConnection.unhideAll(); } - - var renderedBlock = superiorConnection.targetBlock(); - var display = superiorConnection.hidden_ ? 'none' : 'block'; - renderedBlock.getSvgRoot().style.display = display; - renderedBlock.rendered = !superiorConnection.hidden_; } }; @@ -358,17 +359,17 @@ Blockly.RenderedConnection.prototype.connect = function(otherConnection) { */ Blockly.RenderedConnection.prototype.disconnect = function() { var superiorConnection = this.isSuperior() ? this : this.targetConnection; + var rehide = false; if (this.targetConnection && superiorConnection.hidden_) { superiorConnection.unhideAll(); - var renderedBlock = superiorConnection.targetBlock(); - renderedBlock.getSvgRoot().style.display = 'block'; - renderedBlock.rendered = true; - + rehide = true; + } + Blockly.RenderedConnection.superClass_.disconnect.call(this); + if (rehide) { // Set the hidden state for the connection back to true so shadow blocks // will be hidden. superiorConnection.setHidden(true); } - Blockly.RenderedConnection.superClass_.disconnect.call(this); }; /**