diff --git a/core/trashcan.js b/core/trashcan.js index 459d7ba4b..7fbb79178 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -313,9 +313,13 @@ Blockly.Trashcan.prototype.createDom = function() { this.svgLid_.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', this.workspace_.options.pathToMedia + Blockly.SPRITE.url); - Blockly.bindEventWithChecks_(this.svgGroup_, 'mouseup', this, this.click); // bindEventWithChecks_ quashes events too aggressively. See: // https://groups.google.com/forum/#!topic/blockly/QF4yB9Wx00s + // Using bindEventWithChecks_ for blocking mousedown causes issue in mobile. + // See #4303 + Blockly.bindEvent_( + this.svgGroup_, 'mousedown', this, this.blockMouseDownWhenOpenable_); + Blockly.bindEvent_(this.svgGroup_, 'mouseup', this, this.click); // Bind to body instead of this.svgGroup_ so that we don't get lid jitters Blockly.bindEvent_(body, 'mouseover', this, this.mouseOver_); Blockly.bindEvent_(body, 'mouseout', this, this.mouseOut_); @@ -566,6 +570,17 @@ Blockly.Trashcan.prototype.fireUiEvent_ = function(trashcanOpen) { Blockly.Events.fire(uiEvent); }; +/** + * Prevents a workspace scroll and click event if the trashcan has blocks. + * @param {!Event} e A mouse down event. + * @private + */ +Blockly.Trashcan.prototype.blockMouseDownWhenOpenable_ = function(e) { + if (!this.contentsIsOpen() && this.hasContents_()) { + e.stopPropagation(); // Don't start a workspace scroll. + } +}; + /** * Indicate that the trashcan can be clicked (by opening it) if it has blocks. * @private