From b14bbe7e6632f0b2a3960163588643c88eb4bba9 Mon Sep 17 00:00:00 2001 From: Monica Kozbial Date: Thu, 27 Feb 2020 10:30:14 -0800 Subject: [PATCH] Check if WidgetDiv is visible before hide logic. (#3716) --- core/widgetdiv.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/core/widgetdiv.js b/core/widgetdiv.js index dc3819281..e4a63c542 100644 --- a/core/widgetdiv.js +++ b/core/widgetdiv.js @@ -91,16 +91,19 @@ Blockly.WidgetDiv.show = function(newOwner, rtl, dispose) { * Destroy the widget and hide the div. */ Blockly.WidgetDiv.hide = function() { - var div = Blockly.WidgetDiv.DIV; - if (Blockly.WidgetDiv.owner_) { - Blockly.WidgetDiv.owner_ = null; - div.style.display = 'none'; - div.style.left = ''; - div.style.top = ''; - Blockly.WidgetDiv.dispose_ && Blockly.WidgetDiv.dispose_(); - Blockly.WidgetDiv.dispose_ = null; - div.innerHTML = ''; + if (!Blockly.WidgetDiv.isVisible()) { + return; } + Blockly.WidgetDiv.owner_ = null; + + var div = Blockly.WidgetDiv.DIV; + div.style.display = 'none'; + div.style.left = ''; + div.style.top = ''; + Blockly.WidgetDiv.dispose_ && Blockly.WidgetDiv.dispose_(); + Blockly.WidgetDiv.dispose_ = null; + div.innerHTML = ''; + if (Blockly.WidgetDiv.rendererClassName_) { Blockly.utils.dom.removeClass(div, Blockly.WidgetDiv.rendererClassName_); Blockly.WidgetDiv.rendererClassName_ = null;