From 8ca2c148742dbc33ed73fd87861e60036603bd2d Mon Sep 17 00:00:00 2001 From: David Battersby Date: Fri, 31 Jan 2025 17:18:24 +0400 Subject: [PATCH] FIX: switch panel back to forum last known url (#31092) Previously the return to forum link would automatically take you to the forum homepage, however this was not intended functionality. We should attempt to take the user to their last viewed forum page. This change fixes a bug in how we determined what the destination link should be. Internal ref: /t/110508 --- .../discourse/app/components/sidebar/switch-panel-buttons.gjs | 2 +- .../javascripts/discourse/app/lib/sidebar/custom-sections.js | 2 +- plugins/chat/spec/system/separate_sidebar_mode_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/sidebar/switch-panel-buttons.gjs b/app/assets/javascripts/discourse/app/components/sidebar/switch-panel-buttons.gjs index 3d1ef6d9153..58b8a666785 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/switch-panel-buttons.gjs +++ b/app/assets/javascripts/discourse/app/components/sidebar/switch-panel-buttons.gjs @@ -16,7 +16,7 @@ export default class SwitchPanelButtons extends Component { this.isSwitching = true; this.sidebarState.currentPanel.lastKnownURL = this.router.currentURL; - const destination = panel?.switchButtonDefaultUrl || panel?.lastKnownURL; + const destination = panel?.switchButtonDefaultUrl; if (!destination) { return; } diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/custom-sections.js b/app/assets/javascripts/discourse/app/lib/sidebar/custom-sections.js index b53657a23ac..c0c1df268e2 100644 --- a/app/assets/javascripts/discourse/app/lib/sidebar/custom-sections.js +++ b/app/assets/javascripts/discourse/app/lib/sidebar/custom-sections.js @@ -21,7 +21,7 @@ class MainSidebarPanel { } get switchButtonDefaultUrl() { - return "/"; + return this?.lastKnownURL || "/"; } } diff --git a/plugins/chat/spec/system/separate_sidebar_mode_spec.rb b/plugins/chat/spec/system/separate_sidebar_mode_spec.rb index 09444505a45..cb414a61644 100644 --- a/plugins/chat/spec/system/separate_sidebar_mode_spec.rb +++ b/plugins/chat/spec/system/separate_sidebar_mode_spec.rb @@ -221,7 +221,7 @@ RSpec.describe "Separate sidebar mode", type: :system do expect(channel_browse_page.component).to be_present sidebar_component.switch_to_main - expect(page).to have_current_path("/discuss/") + expect(page).to have_current_path("/discuss/about") end end end