Check if WidgetDiv is visible before hide logic. (#3716)

This commit is contained in:
Monica Kozbial
2020-02-27 10:30:14 -08:00
committed by GitHub
parent ec8d76f143
commit b14bbe7e66

View File

@@ -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_) {
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;