From bf572ec3e6835159d6330b3ed5a24436fbe4a6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Tue, 5 Apr 2022 13:24:32 +0000 Subject: [PATCH] [FIX] mail: guard all messaging root.el MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `this.root.el` can become undefined, so it should always be guarded. closes odoo/odoo#88053 X-original-commit: 2e634bb431642fbe21b61d61354c85282c365d40 Signed-off-by: Sébastien Theys (seb) Signed-off-by: Alexandre Kühn (aku) --- .../src/components/attachment_viewer/attachment_viewer.js | 3 +++ .../src/components/autocomplete_input/autocomplete_input.js | 6 ++++++ .../mail/static/src/components/chat_window/chat_window.js | 3 +++ .../chat_window_hidden_menu/chat_window_hidden_menu.js | 6 ++++++ .../components/composer_suggestion/composer_suggestion.js | 1 + .../components/composer_text_input/composer_text_input.js | 3 +++ 6 files changed, 22 insertions(+) diff --git a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js index 838ec03cde9..9e9c0772b60 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js @@ -50,6 +50,9 @@ export class AttachmentViewer extends Component { } _mounted() { + if (!this.root.el) { + return; + } this.root.el.focus(); this._handleImageLoad(); this._hideUnwantedPdfJsButtons(); 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 c7cb07b2694..adf2bc34f81 100644 --- a/addons/mail/static/src/components/autocomplete_input/autocomplete_input.js +++ b/addons/mail/static/src/components/autocomplete_input/autocomplete_input.js @@ -22,6 +22,9 @@ export class AutocompleteInput extends Component { } _mounted() { + if (!this.root.el) { + return; + } if (this.props.isFocusOnMount) { this.root.el.focus(); } @@ -48,6 +51,9 @@ export class AutocompleteInput extends Component { } _willUnmount() { + if (!this.root.el) { + return; + } $(this.root.el).autocomplete('destroy'); } 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 83bde7cf462..3368d487fa1 100644 --- a/addons/mail/static/src/components/chat_window/chat_window.js +++ b/addons/mail/static/src/components/chat_window/chat_window.js @@ -84,6 +84,9 @@ export class ChatWindow extends Component { // chat window is being deleted return; } + if (!this.root.el) { + return; + } if (this.chatWindow.isDoFocus) { this.chatWindow.update({ isDoFocus: false }); if (this._inputRef.el) { diff --git a/addons/mail/static/src/components/chat_window_hidden_menu/chat_window_hidden_menu.js b/addons/mail/static/src/components/chat_window_hidden_menu/chat_window_hidden_menu.js index 5c7aecc676c..2d90f864ebe 100644 --- a/addons/mail/static/src/components/chat_window_hidden_menu/chat_window_hidden_menu.js +++ b/addons/mail/static/src/components/chat_window_hidden_menu/chat_window_hidden_menu.js @@ -28,11 +28,17 @@ export class ChatWindowHiddenMenu extends Component { } _mounted() { + if (!this.root.el) { + return; + } this._apply(); document.addEventListener('click', this._onClickCaptureGlobal, true); } _patched() { + if (!this.root.el) { + return; + } this._apply(); } diff --git a/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js b/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js index fad357f3d4f..cda1885719e 100644 --- a/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js +++ b/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js @@ -72,6 +72,7 @@ export class ComposerSuggestion extends Component { */ _update() { if ( + this.root.el && this.composerView && this.composerView.hasToScrollToActiveSuggestion && this.props.isActive 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 94a09ea4204..227b2c5201f 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 @@ -114,6 +114,9 @@ export class ComposerTextInput extends Component { if (!this.composerView) { return; } + if (!this.root.el) { + return; + } if (this.composerView.doFocus) { this.composerView.update({ doFocus: false }); if (this.messaging.device.isMobile) {