From 2c9da836e5829b8a3d3a36afbeebfdd78f36d542 Mon Sep 17 00:00:00 2001 From: Romain Estievenart Date: Fri, 22 Oct 2021 13:15:57 +0000 Subject: [PATCH] [FIX] mail: keyboard shouldn't pop on WebRTC call on mobile devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce: 1. Log on odoo with a user A on mobile device 2. Log on odoo with a user B on desktop 3. User B call user A 4. User A answer the call and the keyboard popup on the screen => BUG To avoid this behavior, we disable the input auto-focus when we open a chat window like other chatting app on mobile devices (like: Signal, Messenger, WhatsApp...) closes odoo/odoo#78864 X-original-commit: cf36921df8dff114f26a161c4f9d2f6a05ac2adb Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/components/composer/composer.js | 4 ++-- addons/mail/static/src/models/chat_window/chat_window.js | 6 +++--- addons/mail/static/src/models/device/device.js | 2 +- addons/mail/static/src/models/discuss/discuss.js | 6 +++--- addons/mail/static/src/models/thread/thread.js | 8 +++++--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/addons/mail/static/src/components/composer/composer.js b/addons/mail/static/src/components/composer/composer.js index de206c614a2..150bbd9cb97 100644 --- a/addons/mail/static/src/components/composer/composer.js +++ b/addons/mail/static/src/components/composer/composer.js @@ -160,7 +160,7 @@ export class Composer extends Component { */ _onClickAddAttachment() { this._fileUploaderRef.comp.openBrowserFileUploader(); - if (!this.env.device.isMobile) { + if (!this.messaging.device.isMobileDevice) { this.composerView.update({ doFocus: true }); } } @@ -248,7 +248,7 @@ export class Composer extends Component { ev.stopPropagation(); this._textInputRef.comp.saveStateInStore(); this.composerView.insertIntoTextInput(ev.detail.unicode); - if (!this.env.device.isMobile) { + if (!this.messaging.device.isMobileDevice) { this.composerView.update({ doFocus: true }); } } diff --git a/addons/mail/static/src/models/chat_window/chat_window.js b/addons/mail/static/src/models/chat_window/chat_window.js index b0f8647d8c6..036ca8b12a8 100644 --- a/addons/mail/static/src/models/chat_window/chat_window.js +++ b/addons/mail/static/src/models/chat_window/chat_window.js @@ -36,7 +36,7 @@ function factory(dependencies) { if (notifyServer === undefined) { notifyServer = !this.messaging.device.isMobile; } - if (this.env.device.isMobile && !this.messaging.discuss.isOpen) { + if (this.messaging.device.isMobile && !this.messaging.discuss.isOpen) { // If we are in mobile and discuss is not open, it means the // chat window was opened from the messaging menu. In that // case it should be re-opened to simulate it was always @@ -105,14 +105,14 @@ function factory(dependencies) { /** * Makes this chat window active, which consists of making it visible, - * unfolding it, and focusing it. + * unfolding it, and focusing it if the user isn't on a mobile device. * * @param {Object} [options] */ makeActive(options) { this.makeVisible(); this.unfold(options); - if ((options && options.focus !== undefined) ? options.focus : true) { + if ((options && options.focus !== undefined) ? options.focus : !this.messaging.device.isMobileDevice) { this.focus(); } } diff --git a/addons/mail/static/src/models/device/device.js b/addons/mail/static/src/models/device/device.js index 74e5d84a423..02a31b07a89 100644 --- a/addons/mail/static/src/models/device/device.js +++ b/addons/mail/static/src/models/device/device.js @@ -50,7 +50,7 @@ function factory(dependencies) { globalWindowInnerHeight: this.env.browser.innerHeight, globalWindowInnerWidth: this.env.browser.innerWidth, isMobile: this.env.device.isMobile, - isMobileDevice: this.env.device.isMobileDevice, + isMobileDevice: this.messaging.device.isMobileDevice, sizeClass: this.env.device.size_class, }); } diff --git a/addons/mail/static/src/models/discuss/discuss.js b/addons/mail/static/src/models/discuss/discuss.js index 5e88418acd8..ffb828e17f3 100644 --- a/addons/mail/static/src/models/discuss/discuss.js +++ b/addons/mail/static/src/models/discuss/discuss.js @@ -207,13 +207,13 @@ function factory(dependencies) { * * @param {mail.thread} thread * @param {Object} [param1={}] - * @param {Boolean} [param1.focus=true] + * @param {Boolean} [param1.focus] */ - async openThread(thread, { focus = true } = {}) { + async openThread(thread, { focus } = {}) { this.update({ thread: link(thread), }); - if (focus) { + if (focus !== undefined ? focus : !this.messaging.device.isMobileDevice) { this.focus(); } if (!this.isOpen) { diff --git a/addons/mail/static/src/models/thread/thread.js b/addons/mail/static/src/models/thread/thread.js index 56aeb82833e..d9eb5ceb8ea 100644 --- a/addons/mail/static/src/models/thread/thread.js +++ b/addons/mail/static/src/models/thread/thread.js @@ -994,9 +994,9 @@ function factory(dependencies) { * * @param {Object} [param0] * @param {boolean} [param0.expanded=false] - * @param {boolean} [param0.focus=true] + * @param {boolean} [param0.focus] */ - async open({ expanded = false, focus = true } = {}) { + async open({ expanded = false, focus } = {}) { const discuss = this.messaging.discuss; // check if thread must be opened in form view if (!['mail.box', 'mail.channel'].includes(this.model)) { @@ -1018,7 +1018,9 @@ function factory(dependencies) { (!device.isMobile && (discuss.isOpen || expanded)) || this.model === 'mail.box' ) { - return discuss.openThread(this, { focus }); + return discuss.openThread(this, { + focus: focus !== undefined ? focus : !this.messaging.device.isMobileDevice, + }); } // thread must be opened in chat window return this.messaging.chatWindowManager.openThread(this, {