From 0f86d6b69cdf7f71b9126550206bce5b4f0c5911 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Mon, 11 Feb 2019 12:57:39 -0800 Subject: [PATCH 1/2] Fixes block input sticking to the screen when navigated away. --- core/inject.js | 1 + core/toolbox.js | 12 ------------ 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/core/inject.js b/core/inject.js index 6a875dbc1..2fcdf6188 100644 --- a/core/inject.js +++ b/core/inject.js @@ -437,6 +437,7 @@ Blockly.init_ = function(mainWorkspace) { */ Blockly.inject.bindDocumentEvents_ = function() { if (!Blockly.documentEventsBound_) { + Blockly.bindEventWithChecks_(document, 'mousedown', null, Blockly.hideChaff); Blockly.bindEventWithChecks_(document, 'scroll', null, Blockly.mainWorkspace.updateInverseScreenCTM .bind(Blockly.mainWorkspace)); diff --git a/core/toolbox.js b/core/toolbox.js index 8c49c360c..e0763ba82 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -160,18 +160,6 @@ Blockly.Toolbox.prototype.init = function() { this.HtmlDiv.setAttribute('dir', workspace.RTL ? 'RTL' : 'LTR'); svg.parentNode.insertBefore(this.HtmlDiv, svg); - // Clicking on toolbox closes popups. - Blockly.bindEventWithChecks_(this.HtmlDiv, 'mousedown', this, - function(e) { - if (Blockly.utils.isRightButton(e) || e.target == this.HtmlDiv) { - // Close flyout. - Blockly.hideChaff(false); - } else { - // Just close popups. - Blockly.hideChaff(true); - } - Blockly.Touch.clearTouchIdentifier(); // Don't block future drags. - }, /*opt_noCaptureIdentifier*/ false, /*opt_noPreventDefault*/ true); var workspaceOptions = { disabledPatternId: workspace.options.disabledPatternId, parentWorkspace: workspace, From 7e3bff255259fd18468058b1c4d83242413604a5 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 21 Feb 2019 14:57:19 -0800 Subject: [PATCH 2/2] Readded the toolbox click subscriber. Added preventing propagation to the toolbox click subscriber. Added clearing touch identifier to the document click subscriber. --- core/inject.js | 5 ++++- core/toolbox.js | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/inject.js b/core/inject.js index 2fcdf6188..7a89b8cb9 100644 --- a/core/inject.js +++ b/core/inject.js @@ -437,7 +437,10 @@ Blockly.init_ = function(mainWorkspace) { */ Blockly.inject.bindDocumentEvents_ = function() { if (!Blockly.documentEventsBound_) { - Blockly.bindEventWithChecks_(document, 'mousedown', null, Blockly.hideChaff); + Blockly.bindEventWithChecks_(document, 'mousedown', null, function() { + Blockly.hideChaff(); + Blockly.Touch.clearTouchIdentifier(); // Don't block future drags. + }); Blockly.bindEventWithChecks_(document, 'scroll', null, Blockly.mainWorkspace.updateInverseScreenCTM .bind(Blockly.mainWorkspace)); diff --git a/core/toolbox.js b/core/toolbox.js index e0763ba82..4047c729c 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -160,6 +160,19 @@ Blockly.Toolbox.prototype.init = function() { this.HtmlDiv.setAttribute('dir', workspace.RTL ? 'RTL' : 'LTR'); svg.parentNode.insertBefore(this.HtmlDiv, svg); + // Clicking on toolbox closes popups. + Blockly.bindEventWithChecks_(this.HtmlDiv, 'mousedown', this, + function(e) { + if (Blockly.utils.isRightButton(e) || e.target == this.HtmlDiv) { + // Close flyout. + Blockly.hideChaff(false); + } else { + // Just close popups. + Blockly.hideChaff(true); + } + Blockly.Touch.clearTouchIdentifier(); // Don't block future drags. + e.stopPropagation(); // Don't let the document handle this event. + }, /*opt_noCaptureIdentifier*/ false, /*opt_noPreventDefault*/ true); var workspaceOptions = { disabledPatternId: workspace.options.disabledPatternId, parentWorkspace: workspace,