mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Mark fields as dirty when the workspace becomes visible. (#3072)
* Mark fields as dirty when the workspace becomes visible.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.<string>|null} check Compatible value type or
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user