diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat-channel-thread.js b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-thread.js index 79a106f0374..10c29fea24c 100644 --- a/plugins/chat/assets/javascripts/discourse/routes/chat-channel-thread.js +++ b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-thread.js @@ -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(); } } diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat-channel-threads.js b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-threads.js index ee66e8cafa0..873ff958378 100644 --- a/plugins/chat/assets/javascripts/discourse/routes/chat-channel-threads.js +++ b/plugins/chat/assets/javascripts/discourse/routes/chat-channel-threads.js @@ -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(); } } diff --git a/plugins/chat/spec/system/navigation_spec.rb b/plugins/chat/spec/system/navigation_spec.rb index 2e7fb0734f9..9099ddd8503 100644 --- a/plugins/chat/spec/system/navigation_spec.rb +++ b/plugins/chat/spec/system/navigation_spec.rb @@ -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