Do not add COLLAPSED_WARNINGS_WARNING by deleting of warning

If some block tries to remove warning with `block.setWarningText(null, block.id)` in collapsed state, the warning will be shown anyway.
This commit is contained in:
Bluefox
2020-05-25 11:40:59 +02:00
committed by GitHub
parent b84d25fe2d
commit 6f3e27cf16

View File

@@ -1135,22 +1135,22 @@ Blockly.BlockSvg.prototype.setWarningText = function(text, opt_id) {
text = null;
}
// Bubble up to add a warning on top-most collapsed block.
var parent = this.getSurroundParent();
var collapsedParent = null;
while (parent) {
if (parent.isCollapsed()) {
collapsedParent = parent;
}
parent = parent.getSurroundParent();
}
if (collapsedParent) {
collapsedParent.setWarningText(Blockly.Msg['COLLAPSED_WARNINGS_WARNING'],
Blockly.BlockSvg.COLLAPSED_WARNING_ID);
}
var changedState = false;
if (typeof text == 'string') {
// Bubble up to add a warning on top-most collapsed block.
var parent = this.getSurroundParent();
var collapsedParent = null;
while (parent) {
if (parent.isCollapsed()) {
collapsedParent = parent;
}
parent = parent.getSurroundParent();
}
if (collapsedParent) {
collapsedParent.setWarningText(Blockly.Msg['COLLAPSED_WARNINGS_WARNING'],
Blockly.BlockSvg.COLLAPSED_WARNING_ID);
}
if (!this.warning) {
this.warning = new Blockly.Warning(this);
changedState = true;