mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
Update toolbox drag target when visibility changes (#4919)
This commit is contained in:
@@ -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<!Blockly.IToolboxItem>}
|
||||
@@ -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_);
|
||||
@@ -514,7 +522,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;
|
||||
}
|
||||
|
||||
@@ -810,7 +818,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();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user