From 842d2749a1f129868acc6cf11888c59ff6fc40b2 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 22 Aug 2024 17:46:41 +0200 Subject: [PATCH] FIX: adds chat-draw-expanded class to body (#28490) To achieve this, the code is now using bodyClass instead of relying on the addChatDrawerStateCallback`. --- .../javascripts/discourse/components/chat-drawer.hbs | 8 ++++++++ .../javascripts/discourse/initializers/chat-setup.js | 8 -------- plugins/chat/spec/system/drawer_spec.rb | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-drawer.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-drawer.hbs index 8db0d03db6f..712f71fabf4 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-drawer.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-drawer.hbs @@ -1,3 +1,11 @@ +{{#if this.chatStateManager.isDrawerActive}} + {{bodyClass "chat-drawer-active"}} +{{/if}} + +{{#if this.chatStateManager.isDrawerExpanded}} + {{bodyClass "chat-drawer-expanded"}} +{{/if}} + {{#if this.chatStateManager.isDrawerActive}}
{ - if (isDrawerActive) { - document.body.classList.add("chat-drawer-active"); - } else { - document.body.classList.remove("chat-drawer-active"); - } - }); - api.addAboutPageActivity("chat_messages", (periods) => { const count = periods["7_days"]; if (count) { diff --git a/plugins/chat/spec/system/drawer_spec.rb b/plugins/chat/spec/system/drawer_spec.rb index 052d39a9a4a..92d4c8ea65d 100644 --- a/plugins/chat/spec/system/drawer_spec.rb +++ b/plugins/chat/spec/system/drawer_spec.rb @@ -112,11 +112,14 @@ RSpec.describe "Drawer", type: :system do it "collapses the drawer" do visit("/") chat_page.open_from_header + expect(page).to have_selector(".chat-drawer.is-expanded") + expect(page).to have_selector("body.chat-drawer-expanded") page.find(".c-navbar").click expect(page).to have_selector(".chat-drawer:not(.is-expanded)") + expect(page).to have_selector("body:not(.chat-drawer-expanded)") end end