Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update toolbox drag target when visibility changes #4919

Merged
merged 2 commits into from
Jun 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion core/toolbox/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>}
Expand Down Expand Up @@ -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_);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
};

/**
Expand Down