diff --git a/app/webpacker/controllers/tabs_and_panels_controller.js b/app/webpacker/controllers/tabs_and_panels_controller.js index b6a119c3e8..e9b208fae7 100644 --- a/app/webpacker/controllers/tabs_and_panels_controller.js +++ b/app/webpacker/controllers/tabs_and_panels_controller.js @@ -15,9 +15,15 @@ export default class extends Controller { // Display panel specified in url anchor const anchors = window.location.toString().split("#"); - const anchor = anchors.length > 1 ? anchors.pop() : ""; + let anchor = anchors.length > 1 ? anchors.pop() : ""; if (anchor != "") { + // Conveniently AngularJs rewrite "example.com#panel" to "example.com#/panel" :( + // strip the starting / if any + if (anchor[0] == "/") { + anchor = anchor.slice(1); + } + this.updateActivePanel(anchor); // tab diff --git a/spec/javascripts/stimulus/tabs_and_panels_controller_test.js b/spec/javascripts/stimulus/tabs_and_panels_controller_test.js index 8b42a528dd..523f5eb04f 100644 --- a/spec/javascripts/stimulus/tabs_and_panels_controller_test.js +++ b/spec/javascripts/stimulus/tabs_and_panels_controller_test.js @@ -87,7 +87,7 @@ describe('TabsAndPanelsController', () => { const { location } = window; const mockLocationToString = (panel) => { // Mocking window.location.toString() - const url = `http://localhost:3000/admin/enterprises/great-shop/edit#!#${panel}` + const url = `http://localhost:3000/admin/enterprises/great-shop/edit#/${panel}` const mockedToString = jest.fn() mockedToString.mockImplementation(() => (url))