diff --git a/addons/mail/static/src/core/common/chat_window_service.js b/addons/mail/static/src/core/common/chat_window_service.js index 5067cb16288..f4772205f73 100644 --- a/addons/mail/static/src/core/common/chat_window_service.js +++ b/addons/mail/static/src/core/common/chat_window_service.js @@ -68,8 +68,9 @@ export class ChatWindowService { : CHAT_WINDOW_END_GAP_WIDTH; const endGap = this.ui.isSmall ? 0 : CHAT_WINDOW_END_GAP_WIDTH; const available = browser.innerWidth - startGap - endGap; - const maxAmountWithoutHidden = Math.floor( - available / (CHAT_WINDOW_WIDTH + CHAT_WINDOW_INBETWEEN_WIDTH) + const maxAmountWithoutHidden = Math.max( + 1, + Math.floor(available / (CHAT_WINDOW_WIDTH + CHAT_WINDOW_INBETWEEN_WIDTH)) ); return maxAmountWithoutHidden; } diff --git a/addons/mail/static/tests/chat_window/chat_window_tests.js b/addons/mail/static/tests/chat_window/chat_window_tests.js index 27b161cb45b..936998bf1d0 100644 --- a/addons/mail/static/tests/chat_window/chat_window_tests.js +++ b/addons/mail/static/tests/chat_window/chat_window_tests.js @@ -236,6 +236,17 @@ QUnit.test("chat window: open / close", async (assert) => { assert.verifySteps(["rpc:channel_fold/open"]); }); +QUnit.test("open chat on very narrow device should work", async (assert) => { + const pyEnv = await startServer(); + patchUiSize({ width: 200 }); + pyEnv["discuss.channel"].create({}); + await start(); + assert.ok(CHAT_WINDOW_WIDTH > 200, "Device is narrower than usual chat window width"); // scenario where this might fail + await click("button i[aria-label='Messages']"); + await click(".o-mail-NotificationItem"); + assert.containsOnce($, ".o-mail-ChatWindow"); +}); + QUnit.test( "Mobile: closing a chat window should not update channel state on the server", async (assert) => {