Skip to content

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

FIX: switch panel back to forum last known url (#31092)

David Battersby8ca2c148742d
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