diff --git a/core/block_svg.js b/core/block_svg.js index 11232da35..e9b709356 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -540,6 +540,16 @@ Blockly.BlockSvg.prototype.getBoundingRectangle = function() { return new Blockly.utils.Rect(top, bottom, left, right); }; +/** + * Notify every input on this block to mark its fields as dirty. + * A dirty field is a field that needs to be re-rendererd. + */ +Blockly.BlockSvg.prototype.markDirty = function() { + for (var i = 0, input; input = this.inputList[i]; i++) { + input.markDirty(); + } +}; + /** * Set whether the block is collapsed or not. * @param {boolean} collapsed True if collapsed. diff --git a/core/field.js b/core/field.js index f8220349d..254802f38 100644 --- a/core/field.js +++ b/core/field.js @@ -688,6 +688,17 @@ Blockly.Field.prototype.setText = function(_newText) { throw Error('setText method is deprecated'); }; +/** + * Force a rerender of the block that this field is installed on, which will + * rerender this field and adjust for any sizing changes. + * Other fields on the same block will not rerender, because their sizes have + * already been recorded. + * @package + */ +Blockly.Field.prototype.markDirty = function() { + this.isDirty_ = true; +}; + /** * Force a rerender of the block that this field is installed on, which will * rerender this field and adjust for any sizing changes. diff --git a/core/input.js b/core/input.js index 3da031451..4409237db 100644 --- a/core/input.js +++ b/core/input.js @@ -206,6 +206,16 @@ Blockly.Input.prototype.setVisible = function(visible) { return renderList; }; +/** + * Mark all fields on this input as dirty. + * @package + */ +Blockly.Input.prototype.markDirty = function() { + for (var y = 0, field; field = this.fieldRow[y]; y++) { + field.markDirty(); + } +}; + /** * Change a connection's compatibility. * @param {string|Array.|null} check Compatible value type or diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 5e5e3ceb7..cb044addb 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -1079,6 +1079,12 @@ Blockly.WorkspaceSvg.prototype.setVisible = function(isVisible) { this.toolbox_.HtmlDiv.style.display = isVisible ? 'block' : 'none'; } if (isVisible) { + var blocks = this.getAllBlocks(false); + // Tell each block on the workspace to mark its fields as dirty. + for (var i = blocks.length - 1; i >= 0; i--) { + blocks[i].markDirty(); + } + this.render(); if (this.toolbox_) { this.toolbox_.position();