From e0673faf410602afa2358defa529a12234402220 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 27 Feb 2019 16:06:37 -0800 Subject: [PATCH] Added event filtering to workspaceChanged in mutator. (#2320) --- core/mutator.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/mutator.js b/core/mutator.js index da50251ea..3799df497 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -141,6 +141,9 @@ Blockly.Mutator.prototype.createEditor_ = function() { var quarkXml = null; } var workspaceOptions = { + // If you want to enable disabling, also remove the + // event filter from workspaceChanged_ . + disable: false, disabledPatternId: this.block_.workspace.options.disabledPatternId, languageTree: quarkXml, parentWorkspace: this.block_.workspace, @@ -315,9 +318,15 @@ Blockly.Mutator.prototype.setVisible = function(visible) { * Update the source block when the mutator's blocks are changed. * Bump down any block that's too high. * Fired whenever a change is made to the mutator's workspace. + * @param {!Blockly.Events.Abstract} e Custom data for event. * @private */ -Blockly.Mutator.prototype.workspaceChanged_ = function() { +Blockly.Mutator.prototype.workspaceChanged_ = function(e) { + if (e.type == Blockly.Events.UI || + (e.type == Blockly.Events.CHANGE && e.element == 'disabled')) { + return; + } + if (!this.workspace_.isDragging()) { var blocks = this.workspace_.getTopBlocks(false); var MARGIN = 20;