diff options
| author | Sébastien Theys <seb@odoo.com> | 2020-10-30 10:36:40 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2020-10-30 10:36:41 +0000 |
| commit | 4ec26d985f33e1fa391c312b89fc611b8d688c96 (patch) | |
| tree | 5e6de2878d7d39e3db753411e94af72c6c66101f | |
| parent | 9d90fd9a2a65ab1ff338bb109426ca93075937fa (diff) | |
[FIX] mail: remove chat window auto-focus on click
This causes more trouble than it's worth, especially with mobile keyboards.
It also prevents from selecting any text in chat window threads.
task-2372553
Part of task-2277543
closes odoo/odoo#61031
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
5 files changed, 7 insertions, 36 deletions
diff --git a/addons/mail/static/src/components/chat_window/chat_window.js b/addons/mail/static/src/components/chat_window/chat_window.js index 0f8598257c3..28e7f08a1fb 100644 --- a/addons/mail/static/src/components/chat_window/chat_window.js +++ b/addons/mail/static/src/components/chat_window/chat_window.js @@ -209,34 +209,6 @@ class ChatWindow extends Component { } /** - * Handle focus of the chat window based on position of click. The click on - * chat window that folds it should NOT set focus on this chat window. - * - * @private - * @param {MouseEvent} ev - */ - _onClick(ev) { - const chatWindowHeader = this._chatWindowHeaderRef.el; - if (chatWindowHeader && chatWindowHeader.contains(ev.target)) { - // handled in _onClickedHeader - return; - } - if (this.chatWindow.isFocused) { - return; - } - if (isEventHandled(ev, 'Message.authorOpenChat')) { - return; - } - if (isEventHandled(ev, 'Message.authorOpenProfile')) { - return; - } - if (isEventHandled(ev, 'PartnerImStatusIcon.openChat')) { - return; - } - this.chatWindow.focus(); - } - - /** * Called when clicking on header of chat window. Usually folds the chat * window. * diff --git a/addons/mail/static/src/components/chat_window/chat_window.xml b/addons/mail/static/src/components/chat_window/chat_window.xml index 240cf0f974c..fad098d953c 100644 --- a/addons/mail/static/src/components/chat_window/chat_window.xml +++ b/addons/mail/static/src/components/chat_window/chat_window.xml @@ -9,7 +9,7 @@ 'o-fullscreen': props.isFullscreen, 'o-mobile': env.messaging.device.isMobile, 'o-new-message': chatWindow and !chatWindow.thread, - }" t-on-click="_onClick" t-on-keydown="_onKeydown" t-on-focusout="_onFocusout" t-att-data-chat-window-local-id="chatWindow ? chatWindow.localId : undefined" t-att-data-thread-local-id="chatWindow ? (chatWindow.thread ? chatWindow.thread.localId : '') : undefined" + }" t-on-keydown="_onKeydown" t-on-focusout="_onFocusout" t-att-data-chat-window-local-id="chatWindow ? chatWindow.localId : undefined" t-att-data-thread-local-id="chatWindow ? (chatWindow.thread ? chatWindow.thread.localId : '') : undefined" > <t t-if="chatWindow"> <ChatWindowHeader diff --git a/addons/mail/static/src/components/composer/composer.js b/addons/mail/static/src/components/composer/composer.js index 95a09f7820f..6c9965a57d1 100644 --- a/addons/mail/static/src/components/composer/composer.js +++ b/addons/mail/static/src/components/composer/composer.js @@ -217,7 +217,9 @@ class Composer extends Component { */ _onClickAddAttachment() { this._fileUploaderRef.comp.openBrowserFileUploader(); - this.focus(); + if (!this.env.device.isMobile) { + this.focus(); + } } /** @@ -302,7 +304,9 @@ class Composer extends Component { ev.stopPropagation(); this._textInputRef.comp.saveStateInStore(); this.composer.insertIntoTextInput(ev.detail.unicode); - this.focus(); + if (!this.env.device.isMobile) { + this.focus(); + } } /** diff --git a/addons/mail/static/src/components/message/message.js b/addons/mail/static/src/components/message/message.js index 6a8c642e0a7..e09f0e4946c 100644 --- a/addons/mail/static/src/components/message/message.js +++ b/addons/mail/static/src/components/message/message.js @@ -11,7 +11,6 @@ const components = { PartnerImStatusIcon: require('mail/static/src/components/partner_im_status_icon/partner_im_status_icon.js'), }; const useStore = require('mail/static/src/component_hooks/use_store/use_store.js'); -const { markEventHandled } = require('mail/static/src/utils/utils.js'); const { timeFromNow } = require('mail.utils'); const { _lt } = require('web.core'); @@ -460,7 +459,6 @@ class Message extends Component { if (!this.hasAuthorOpenChat) { return; } - markEventHandled(ev, 'Message.authorOpenChat'); this.message.author.openChat(); } @@ -472,7 +470,6 @@ class Message extends Component { if (!this.message.author) { return; } - markEventHandled(ev, 'Message.authorOpenProfile'); this.message.author.openProfile(); } diff --git a/addons/mail/static/src/components/partner_im_status_icon/partner_im_status_icon.js b/addons/mail/static/src/components/partner_im_status_icon/partner_im_status_icon.js index 2a9af18f79a..68fbab4f7c9 100644 --- a/addons/mail/static/src/components/partner_im_status_icon/partner_im_status_icon.js +++ b/addons/mail/static/src/components/partner_im_status_icon/partner_im_status_icon.js @@ -2,7 +2,6 @@ odoo.define('mail/static/src/components/partner_im_status_icon/partner_im_status 'use strict'; const useStore = require('mail/static/src/component_hooks/use_store/use_store.js'); -const { markEventHandled } = require('mail/static/src/utils/utils.js'); const { Component } = owl; @@ -47,7 +46,6 @@ class PartnerImStatusIcon extends Component { if (!this.props.hasOpenChat) { return; } - markEventHandled(ev, 'PartnerImStatusIcon.openChat'); this.partner.openChat(); } |
