mirror of
https://github.com/google/blockly.git
synced 2026-01-20 07:17:10 +01:00
Fix RTL text field positioning bug by ensuring a reflow (#2779)
This commit is contained in:
@@ -161,7 +161,17 @@ Blockly.FieldTextInput.prototype.render_ = function() {
|
||||
// This logic is done in render_ rather than doValueInvalid_ or
|
||||
// doValueUpdate_ so that the code is more centralized.
|
||||
if (this.isBeingEdited_) {
|
||||
this.resizeEditor_();
|
||||
if (this.sourceBlock_.RTL) {
|
||||
// in RTL, we need to let the browser reflow before resizing
|
||||
// in order to get the correct bounding box of the borderRect
|
||||
// avoiding issue #2777.
|
||||
var field = this;
|
||||
setTimeout(function() {
|
||||
field.resizeEditor_();
|
||||
}, 0);
|
||||
} else {
|
||||
this.resizeEditor_();
|
||||
}
|
||||
if (!this.isTextValid_) {
|
||||
Blockly.utils.dom.addClass(this.htmlInput_, 'blocklyInvalidInput');
|
||||
} else {
|
||||
@@ -247,7 +257,11 @@ Blockly.FieldTextInput.prototype.widgetCreate_ = function() {
|
||||
htmlInput.value = htmlInput.defaultValue = this.value_;
|
||||
htmlInput.untypedDefaultValue_ = this.value_;
|
||||
htmlInput.oldValue_ = null;
|
||||
this.resizeEditor_();
|
||||
// Ensure the browser reflows before resizing to avoid issue #2777.
|
||||
var field = this;
|
||||
setTimeout(function() {
|
||||
field.resizeEditor_();
|
||||
}, 0);
|
||||
|
||||
this.bindInputEvents_(htmlInput);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user