From 4efb465f6adcf8e4f9c6d4daa0b6f90079832af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Fri, 4 Dec 2020 12:54:12 +0000 Subject: [PATCH] [FIX] mail: prevent Safari from indefinitely focusing composer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `setSelectionRange()` on Safari has side-effect to focusing the input element, which is not the case in Chrome and Firefox. Task-2410311 closes odoo/odoo#62886 Signed-off-by: Alexandre Kühn (aku) --- .../composer_text_input/composer_text_input.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 b267c313def..51a7143ec98 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 @@ -165,11 +165,13 @@ class ComposerTextInput extends Component { } this._textareaRef.el.value = this.composer.textInputContent; this._mirroredTextareaRef.el.value = this.composer.textInputContent; - this._textareaRef.el.setSelectionRange( - this.composer.textInputCursorStart, - this.composer.textInputCursorEnd, - this.composer.textInputSelectionDirection, - ); + if (this.composer.hasFocus) { + this._textareaRef.el.setSelectionRange( + this.composer.textInputCursorStart, + this.composer.textInputCursorEnd, + this.composer.textInputSelectionDirection, + ); + } this._updateHeight(); }