From bc9ec4e9e9ae2e73dfe5e02b250971f6b80bf079 Mon Sep 17 00:00:00 2001 From: kozbial Date: Mon, 14 Jun 2021 17:42:44 -0700 Subject: [PATCH 1/2] Update toolbox drag target when visibility changes --- core/toolbox/toolbox.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/core/toolbox/toolbox.js b/core/toolbox/toolbox.js index d96bde6d205..8fae6f5cc23 100644 --- a/core/toolbox/toolbox.js +++ b/core/toolbox/toolbox.js @@ -99,6 +99,13 @@ Blockly.Toolbox = function(workspace) { */ this.contentsDiv_ = null; + /** + * Whether the Toolbox is visible. + * @type {boolean} + * @protected + */ + this.isVisible_ = false; + /** * The list of items in the toolbox. * @type {!Array} @@ -193,6 +200,7 @@ Blockly.Toolbox.prototype.init = function() { this.HtmlDiv = this.createDom_(this.workspace_); Blockly.utils.dom.insertAfter(this.flyout_.createDom('svg'), svg); + this.setVisible(true); this.flyout_.init(workspace); this.render(this.toolboxDef_); @@ -513,7 +521,7 @@ Blockly.Toolbox.prototype.removeStyle = function(style) { * target area should be ignored. */ Blockly.Toolbox.prototype.getClientRect = function() { - if (!this.HtmlDiv) { + if (!this.HtmlDiv || !this.isVisible_) { return null; } @@ -809,7 +817,15 @@ Blockly.Toolbox.prototype.refreshSelection = function() { * @public */ Blockly.Toolbox.prototype.setVisible = function(isVisible) { + if (this.isVisible_ == isVisible) { + return; + } + this.HtmlDiv.style.display = isVisible ? 'block' : 'none'; + this.isVisible_ = isVisible; + // Invisible toolbox is ignored as drag targets and must have the drag target + // updated. + this.workspace_.recordDragTargets(); }; /** From 702e57a2a8219bd3bace2c27f9901c72ddd05a78 Mon Sep 17 00:00:00 2001 From: kozbial Date: Thu, 17 Jun 2021 11:52:17 -0700 Subject: [PATCH 2/2] update comparison operator --- core/toolbox/toolbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/toolbox/toolbox.js b/core/toolbox/toolbox.js index 8fae6f5cc23..dcf22c7cb67 100644 --- a/core/toolbox/toolbox.js +++ b/core/toolbox/toolbox.js @@ -817,7 +817,7 @@ Blockly.Toolbox.prototype.refreshSelection = function() { * @public */ Blockly.Toolbox.prototype.setVisible = function(isVisible) { - if (this.isVisible_ == isVisible) { + if (this.isVisible_ === isVisible) { return; }