[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#61078

X-original-commit: 4ec26d985f33e1fa391c312b89fc611b8d688c96
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Sébastien Theys
2020-10-30 16:40:03 +00:00
parent 71b3fc7c17
commit 06ca3e8d0d
5 changed files with 7 additions and 36 deletions
@@ -208,34 +208,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.
@@ -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
@@ -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();
}
}
/**
@@ -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');
@@ -455,7 +454,6 @@ class Message extends Component {
if (!this.hasAuthorOpenChat) {
return;
}
markEventHandled(ev, 'Message.authorOpenChat');
this.message.author.openChat();
}
@@ -467,7 +465,6 @@ class Message extends Component {
if (!this.message.author) {
return;
}
markEventHandled(ev, 'Message.authorOpenProfile');
this.message.author.openProfile();
}
@@ -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();
}