diff --git a/addons/mail/static/src/components/autocomplete_input/autocomplete_input.js b/addons/mail/static/src/components/autocomplete_input/autocomplete_input.js index 27e80295c27..b95755d6b69 100644 --- a/addons/mail/static/src/components/autocomplete_input/autocomplete_input.js +++ b/addons/mail/static/src/components/autocomplete_input/autocomplete_input.js @@ -3,7 +3,7 @@ import { useComponentToModel } from '@mail/component_hooks/use_component_to_model'; import { registerMessagingComponent } from '@mail/utils/messaging_component'; -const { Component, onMounted, onWillUnmount, useEffect } = owl; +const { Component, onMounted, onWillUnmount } = owl; export class AutocompleteInput extends Component { @@ -15,12 +15,6 @@ export class AutocompleteInput extends Component { useComponentToModel({ fieldName: 'component' }); onMounted(() => this._mounted()); onWillUnmount(() => this._willUnmount()); - useEffect(() => { - if (this.props.inputRef) { - this.props.inputRef.el = this.root.el; - return () => this.props.inputRef.el = null; - } - }) } _mounted() { @@ -178,10 +172,6 @@ Object.assign(AutocompleteInput, { type: Function, optional: true, }, - inputRef: { - type: { el: Object }, - optional: true, - }, }, template: 'mail.AutocompleteInput', }); 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 1827651f3e3..b8e99217e72 100644 --- a/addons/mail/static/src/components/chat_window/chat_window.js +++ b/addons/mail/static/src/components/chat_window/chat_window.js @@ -46,8 +46,12 @@ export class ChatWindow extends Component { } if (this.chatWindow.isDoFocus) { this.chatWindow.update({ isDoFocus: false }); - if (this._inputRef.el) { - this._inputRef.el.focus(); + if ( + this.chatWindow.newMessageAutocompleteInputView && + this.chatWindow.newMessageAutocompleteInputView.component && + this.chatWindow.newMessageAutocompleteInputView.component.root.el + ) { + this.chatWindow.newMessageAutocompleteInputView.component.root.el.focus(); } } } 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 a82e0d31a17..87038e44b84 100644 --- a/addons/mail/static/src/components/chat_window/chat_window.xml +++ b/addons/mail/static/src/components/chat_window/chat_window.xml @@ -17,7 +17,6 @@ className="'o_ChatWindow_header flex-grow-0 flex-shrink-0'" chatWindow="chatWindow" record="chatWindow.chatWindowHeaderView" - onClicked="chatWindow.onClickHeader" /> @@ -41,7 +40,6 @@ record="chatWindow.newMessageAutocompleteInputView" select="chatWindow.onAutocompleteSelect" source="chatWindow.onAutocompleteSource" - inputRef="_inputRef" /> diff --git a/addons/mail/static/src/components/chat_window_header/chat_window_header.js b/addons/mail/static/src/components/chat_window_header/chat_window_header.js index 1cf1ab161c7..c74fba50e2e 100644 --- a/addons/mail/static/src/components/chat_window_header/chat_window_header.js +++ b/addons/mail/static/src/components/chat_window_header/chat_window_header.js @@ -1,7 +1,6 @@ /** @odoo-module **/ import { registerMessagingComponent } from '@mail/utils/messaging_component'; -import { isEventHandled } from '@mail/utils/utils'; const { Component } = owl; @@ -25,40 +24,12 @@ export class ChatWindowHeader extends Component { return this.props.record; } - //-------------------------------------------------------------------------- - // Handlers - //-------------------------------------------------------------------------- - - /** - * @private - * @param {MouseEvent} ev - */ - _onClick(ev) { - if ( - isEventHandled(ev, 'ChatWindow.onClickCommand') || - isEventHandled(ev, 'ChatWindowHeader.ClickShiftNext') || - isEventHandled(ev, 'ChatWindowHeader.ClickShiftPrev') || - isEventHandled(ev, 'ChatWindow.onClickHideMemberList') || - isEventHandled(ev, 'ChatWindow.onClickShowMemberList') - ) { - return; - } - const chatWindow = this.chatWindow; - if (this.props.onClicked) { - this.props.onClicked({ chatWindow }); - } - } - } Object.assign(ChatWindowHeader, { props: { chatWindow: Object, record: Object, - onClicked: { - type: Function, - optional: true, - }, }, template: 'mail.ChatWindowHeader', }); diff --git a/addons/mail/static/src/components/chat_window_header/chat_window_header.xml b/addons/mail/static/src/components/chat_window_header/chat_window_header.xml index acf049ceed7..8b1a5e2f66b 100644 --- a/addons/mail/static/src/components/chat_window_header/chat_window_header.xml +++ b/addons/mail/static/src/components/chat_window_header/chat_window_header.xml @@ -3,7 +3,7 @@ -
+
diff --git a/addons/mail/static/src/components/chat_window_hidden_menu_item/chat_window_hidden_menu_item.xml b/addons/mail/static/src/components/chat_window_hidden_menu_item/chat_window_hidden_menu_item.xml index a5e33bffe88..80b3874032d 100644 --- a/addons/mail/static/src/components/chat_window_hidden_menu_item/chat_window_hidden_menu_item.xml +++ b/addons/mail/static/src/components/chat_window_hidden_menu_item/chat_window_hidden_menu_item.xml @@ -7,7 +7,6 @@ className="'o_ChatWindowHiddenMenuItem_chatWindowHeader opacity-100-hover'" record="chatWindowHeaderView" chatWindow="chatWindowHeaderView.chatWindowOwner" - onClicked="chatWindowHeaderView.chatWindowOwner.onClickFromChatWindowHiddenMenu" /> diff --git a/addons/mail/static/src/models/chat_window_header_view.js b/addons/mail/static/src/models/chat_window_header_view.js index 4fbd8229827..35d9b2e2289 100644 --- a/addons/mail/static/src/models/chat_window_header_view.js +++ b/addons/mail/static/src/models/chat_window_header_view.js @@ -2,10 +2,32 @@ import { registerModel } from '@mail/model/model_core'; import { one } from '@mail/model/model_field'; +import { isEventHandled } from '@mail/utils/utils'; registerModel({ name: 'ChatWindowHeaderView', identifyingFields: ['chatWindowOwner'], + recordMethods: { + /** + * @param {MouseEvent} ev + */ + onClick(ev) { + if ( + isEventHandled(ev, 'ChatWindow.onClickCommand') || + isEventHandled(ev, 'ChatWindowHeader.ClickShiftNext') || + isEventHandled(ev, 'ChatWindowHeader.ClickShiftPrev') || + isEventHandled(ev, 'ChatWindow.onClickHideMemberList') || + isEventHandled(ev, 'ChatWindow.onClickShowMemberList') + ) { + return; + } + if (!this.chatWindowOwner.isVisible) { + this.chatWindowOwner.onClickFromChatWindowHiddenMenu(ev); + } else { + this.chatWindowOwner.onClickHeader(ev); + } + }, + }, fields: { chatWindowOwner: one('ChatWindow', { inverse: 'chatWindowHeaderView',