From 6b2117049cdcb121c1c3b4335ecd3e7fa4f41bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Wed, 26 Jul 2023 09:15:19 +0000 Subject: [PATCH] [FIX] mail: no crash when closing chat window from barcode app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce: - Open barcodde app - Go to Operations > Delivery Orders - Click on avatar button to open chat - Click on back button Traceback: ``` Cannot read properties of null (reading 'click') ``` This happens because closing the chat window attempts to open the messaging menu in mobile. This assumes chat windows are working in `/web` and the systray is available. Barcode app is special because it's in `/web` but the systray is not available. This commit fixes the issue by opening the messaging menu if it can, otherwise it silently does nothing. Task-3439660 closes odoo/odoo#129858 X-original-commit: 399f191dc1bb40d352890607413fa72462f1a99d Signed-off-by: Alexandre Kühn (aku) Signed-off-by: Matthieu Stockbauer (tsm) --- addons/mail/static/src/core/web/chat_window_service_patch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/static/src/core/web/chat_window_service_patch.js b/addons/mail/static/src/core/web/chat_window_service_patch.js index 6f5668129a9..3c8b2f08934 100644 --- a/addons/mail/static/src/core/web/chat_window_service_patch.js +++ b/addons/mail/static/src/core/web/chat_window_service_patch.js @@ -12,7 +12,7 @@ patch(ChatWindowService.prototype, "mail/core/web", { // chat window was opened from the messaging menu. In that // case it should be re-opened to simulate it was always // there in the background. - document.querySelector(".o_menu_systray i[aria-label='Messages']").click(); + document.querySelector(".o_menu_systray i[aria-label='Messages']")?.click(); // ensure messaging menu is opened before chat window is closed await Promise.resolve(); }