From f06aed4710a0443dd3ca703709a8de25feee59e6 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Mon, 6 Nov 2017 11:42:01 -0800 Subject: [PATCH] Fix text input widget position in RTL --- core/field_textinput.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/core/field_textinput.js b/core/field_textinput.js index d75430288..82a0c3158 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -301,17 +301,15 @@ Blockly.FieldTextInput.prototype.validate_ = function() { */ Blockly.FieldTextInput.prototype.resizeEditor_ = function() { var div = Blockly.WidgetDiv.DIV; - var bBox = this.fieldGroup_.getBBox(); - div.style.width = bBox.width * this.workspace_.scale + 'px'; - div.style.height = bBox.height * this.workspace_.scale + 'px'; - var xy = this.getAbsoluteXY_(); + var bBox = this.getScaledBBox_(); + div.style.width = bBox.right - bBox.left + 'px'; + div.style.height = bBox.bottom - bBox.top + 'px'; + // In RTL mode block fields and LTR input fields the left edge moves, // whereas the right edge is fixed. Reposition the editor. - if (this.sourceBlock_.RTL) { - var borderBBox = this.getScaledBBox_(); - xy.x += borderBBox.width; - xy.x -= div.offsetWidth; - } + var x = this.sourceBlock_.RTL ? bBox.right - div.offsetWidth : bBox.left; + var xy = new goog.math.Coordinate(x, bBox.top); + // Shift by a few pixels to line up exactly. xy.y += 1; if (goog.userAgent.GECKO && Blockly.WidgetDiv.DIV.style.top) {