From 785fdb6cea6ee7d9a1a4e4c6a44403a275a67763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Fri, 15 Jan 2021 17:23:46 +0000 Subject: [FIX] mail: prevent composer cursor from randomly changing position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit task-2388600 closes odoo/odoo#62446 Signed-off-by: Alexandre Kühn (aku) --- .../composer_text_input/composer_text_input.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'addons/mail/static/src/components/composer_text_input') diff --git a/addons/mail/static/src/components/composer_text_input/composer_text_input.js b/addons/mail/static/src/components/composer_text_input/composer_text_input.js index 1b71e22afe1..3fba8115254 100644 --- a/addons/mail/static/src/components/composer_text_input/composer_text_input.js +++ b/addons/mail/static/src/components/composer_text_input/composer_text_input.js @@ -153,14 +153,16 @@ class ComposerTextInput extends Component { if (!this.composer) { return; } - this._textareaRef.el.value = this.composer.textInputContent; - this._mirroredTextareaRef.el.value = this.composer.textInputContent; - if (this.composer.hasFocus) { - this._textareaRef.el.setSelectionRange( - this.composer.textInputCursorStart, - this.composer.textInputCursorEnd, - this.composer.textInputSelectionDirection, - ); + if (this.composer.isLastStateChangeProgrammatic) { + this._textareaRef.el.value = this.composer.textInputContent; + if (this.composer.hasFocus) { + this._textareaRef.el.setSelectionRange( + this.composer.textInputCursorStart, + this.composer.textInputCursorEnd, + this.composer.textInputSelectionDirection, + ); + } + this.composer.update({ isLastStateChangeProgrammatic: false }); } this._updateHeight(); } @@ -171,6 +173,7 @@ class ComposerTextInput extends Component { * @private */ _updateHeight() { + this._mirroredTextareaRef.el.value = this.composer.textInputContent; this._textareaRef.el.style.height = (this._mirroredTextareaRef.el.scrollHeight) + "px"; } -- cgit v1.2.3