Skip to content

A platform for community discussion. Free, open, simple.

FIX: nullify active channel only when not on a chat channel (#19319)

Joffrey JAFFEUX1d42cc94a2c7
diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat.js b/plugins/chat/assets/javascripts/discourse/routes/chat.js
index 9a2b222f21f..4c49766601d 100644
--- a/plugins/chat/assets/javascripts/discourse/routes/chat.js
+++ b/plugins/chat/assets/javascripts/discourse/routes/chat.js
@@ -36,10 +36,7 @@ export default class ChatRoute extends DiscourseRoute {
transition.abort();
let URL = transition.intent.url;
- if (
- transition.targetName === "chat.channel.index" ||
- transition.targetName === "chat.channel"
- ) {
+ if (transition.targetName.startsWith("chat.channel")) {
URL ??= this.router.urlFor(
transition.targetName,
...transition.intent.contexts
@@ -75,7 +72,9 @@ export default class ChatRoute extends DiscourseRoute {
@action
willTransition(transition) {
- this.chat.setActiveChannel(null);
+ if (!transition?.to?.name?.startsWith("chat.channel")) {
+ this.chat.setActiveChannel(null);
+ }
if (!transition?.to?.name?.startsWith("chat.")) {
this.chatStateManager.storeChatURL();
diff --git a/plugins/chat/spec/system/navigation_spec.rb b/plugins/chat/spec/system/navigation_spec.rb
index e0a51aa0fe1..0e69f4f5845 100644
--- a/plugins/chat/spec/system/navigation_spec.rb
+++ b/plugins/chat/spec/system/navigation_spec.rb
@@ -278,6 +278,14 @@ RSpec.describe "Navigation", type: :system, js: true do
end
end
+ context "when going back to channel from channel settings in full page" do
+ it "activates the channel in the sidebar" do
+ visit("/chat/channel/#{category_channel.id}/#{category_channel.slug}/info/settings")
+ find(".chat-full-page-header__back-btn").click
+ expect(page).to have_content(message.message)
+ end
+ end
+
context "when clicking logo from a channel in full page" do
it "deactivates the channel in the sidebar" do
visit("/chat/channel/#{category_channel.id}/#{category_channel.slug}")