From 6f3e27cf1669396c1f6b5102e07e9bdb48d9b24d Mon Sep 17 00:00:00 2001 From: Bluefox Date: Mon, 25 May 2020 11:40:59 +0200 Subject: [PATCH] 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. --- core/block_svg.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/core/block_svg.js b/core/block_svg.js index 4ed10091b..46d187e0a 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -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;