From f06d7b3cfd1ee5523b8fa6943467b7347b4bd104 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Thu, 2 Jan 2020 17:19:32 -0800 Subject: [PATCH] Fix scrolled text input widgetdiv positioning. (#3533) * Fix scrolled text input widgetdiv positioning. * Fix dropdown div bounds element when scrolled. --- core/dropdowndiv.js | 14 +++++++------- core/field.js | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/dropdowndiv.js b/core/dropdowndiv.js index 90672ea38..6de2ae775 100644 --- a/core/dropdowndiv.js +++ b/core/dropdowndiv.js @@ -377,16 +377,16 @@ Blockly.DropDownDiv.show = function(owner, rtl, primaryX, primaryY, * @private */ Blockly.DropDownDiv.getBoundsInfo_ = function() { - var boundPosition = Blockly.DropDownDiv.boundsElement_ - .getBoundingClientRect(); + var boundPosition = Blockly.utils.style.getPageOffset( + /** @type {!Element} */ (Blockly.DropDownDiv.boundsElement_)); var boundSize = Blockly.utils.style.getSize( - Blockly.DropDownDiv.boundsElement_); + /** @type {!Element} */ (Blockly.DropDownDiv.boundsElement_)); return { - left: boundPosition.left, - right: boundPosition.left + boundSize.width, - top: boundPosition.top, - bottom: boundPosition.top + boundSize.height, + left: boundPosition.x, + right: boundPosition.x + boundSize.width, + top: boundPosition.y, + bottom: boundPosition.y + boundSize.height, width: boundSize.width, height: boundSize.height }; diff --git a/core/field.js b/core/field.js index 2d392f981..ae7d1cdd7 100644 --- a/core/field.js +++ b/core/field.js @@ -698,9 +698,10 @@ Blockly.Field.prototype.getScaledBBox = function() { scaledHeight += 1 * scale; } } else { - var xy = this.borderRect_.getBoundingClientRect(); - var scaledWidth = xy.width; - var scaledHeight = xy.height; + var bBox = this.borderRect_.getBoundingClientRect(); + var xy = Blockly.utils.style.getPageOffset(this.borderRect_); + var scaledWidth = bBox.width; + var scaledHeight = bBox.height; } return { top: xy.y,