A platform for community discussion. Free, open, simple.
UX: ensure when a chat channel is a homepage mobile can get to topics (#44714)
Kris5c414da3409e
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-header.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-header.gjsindex 023518a0cad..472c469138e 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-header.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-header.gjs@@ -3,6 +3,8 @@ import { tracked } from "@glimmer/tracking";import { LinkTo } from "@ember/routing";import { service } from "@ember/service";import getURL from "discourse/lib/get-url";+import { discoveryHomepageRoute } from "discourse/lib/homepage-router-overrides";+import { defaultHomepage } from "discourse/lib/utilities";import dIcon from "discourse/ui-kit/helpers/d-icon";import { i18n } from "discourse-i18n";@@ -37,11 +39,20 @@ export default class ChatHeader extends Component {}get forumLink() {- return getURL(this.previousURL ?? this.router.rootURL);+ if (this.previousURL) {+ return getURL(this.previousURL);+ }++ // `/` would lead straight back into chat+ if (defaultHomepage() === "chat") {+ return getURL(this.router.urlFor(discoveryHomepageRoute()));+ }++ return getURL(this.router.rootURL);}#updatePreviousURL() {- if (!this.isChatOpen) {+ if (!this.router.currentRouteName?.startsWith("chat")) {this.previousURL = this.router.currentURL;}}diff --git a/plugins/chat/spec/system/homepage_channel_spec.rb b/plugins/chat/spec/system/homepage_channel_spec.rbindex 86748027ae1..714e94dfcd5 100644--- a/plugins/chat/spec/system/homepage_channel_spec.rb+++ b/plugins/chat/spec/system/homepage_channel_spec.rb@@ -68,6 +68,17 @@ RSpec.describe "Chat channel as the homepage" doexpect(page).to have_no_css(".chat-channel")end+ context "when on mobile", mobile: true do+ it "links back to the forum rather than the homepage" do+ visit("/")+ expect(channel_page.messages).to have_message(id: message_1.id)++ chat_page.back_to_channels_list++ expect(page).to have_css(".back-to-forum[href='/latest']")+ end+ end+context "when the user prefers the drawer" doit "still opens full page from the homepage" dovisit("/categories")