FIX: adds chat-draw-expanded class to body (#28490)

To achieve this, the code is now using bodyClass instead of relying on the addChatDrawerStateCallback`.
This commit is contained in:
Joffrey JAFFEUX 2024-08-22 17:46:41 +02:00 committed by GitHub
parent 5fa0496f81
commit 842d2749a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 8 deletions

View File

@ -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}}
<div
data-chat-channel-id={{this.chat.activeChannel.id}}

View File

@ -157,14 +157,6 @@ export default {
id: "chat",
});
api.addChatDrawerStateCallback(({ 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) {

View File

@ -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