FIX: correctly closes panels in threads (#31013)

The following case was bugged:

- visit a thread in full page chat
- click channel title
- click back button in channel navbar
- 💥 you would have a channel with limited width as if there was
still the thread showing next to it, but it was empty
This commit is contained in:
Joffrey JAFFEUX
2025-01-27 16:34:56 +01:00
committed by GitHub
parent c20aa5f671
commit a52a8f4663
3 changed files with 29 additions and 23 deletions

View File

@ -6,7 +6,6 @@ export default class ChatChannelThread extends DiscourseRoute {
@service router;
@service chatStateManager;
@service chat;
@service chatThreadPane;
redirectToChannel(channel, transition) {
transition.abort();
@ -36,15 +35,14 @@ export default class ChatChannelThread extends DiscourseRoute {
}
@action
willTransition(transition) {
if (
transition.targetName === "chat.channel.index" ||
transition.targetName === "chat.channel.near-message" ||
transition.targetName === "chat.index" ||
!transition.targetName.startsWith("chat")
) {
this.chatStateManager.closeSidePanel();
}
activate() {
this.chat.activeMessage = null;
this.chatStateManager.openSidePanel();
}
@action
deactivate() {
this.chatStateManager.closeSidePanel();
}
beforeModel() {
@ -55,7 +53,5 @@ export default class ChatChannelThread extends DiscourseRoute {
) {
this.controllerFor("chat-channel-thread").set("targetMessageId", null);
}
this.chatStateManager.openSidePanel();
}
}

View File

@ -16,24 +16,16 @@ export default class ChatChannelThreads extends DiscourseRoute {
this.router.transitionTo("chat.channel", ...channel.routeModels);
return;
}
this.chatStateManager.openSidePanel();
}
@action
activate() {
this.chat.activeMessage = null;
this.chatStateManager.openSidePanel();
}
@action
willTransition(transition) {
if (
transition.targetName === "chat.channel.index" ||
transition.targetName === "chat.channel.near-message" ||
transition.targetName === "chat.index" ||
!transition.targetName.startsWith("chat")
) {
this.chatStateManager.closeSidePanel();
}
deactivate() {
this.chatStateManager.closeSidePanel();
}
}

View File

@ -139,6 +139,24 @@ RSpec.describe "Navigation", type: :system do
end
end
context "when opening channel settings from thread" do
fab!(:thread) { Fabricate(:chat_thread, channel: category_channel, use_service: true) }
before do
category_channel.update!(threading_enabled: true)
Fabricate(:chat_message, thread: thread, use_service: true)
thread.add(current_user)
end
it "correctly closes the side panel" do
chat_page.visit_thread(thread)
find(".c-navbar__channel-title").click
expect(page).to have_no_selector(".main-chat-outlet.has-side-panel-expanded")
end
end
context "when collapsing full page with no previous state" do
it "redirects to home page" do
chat_page.open