mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix TabsAndPanelsController now that #! are removed from url
This PR https://github.com/openfoodfoundation/openfoodnetwork/pull/9729 remove #! from url. But unfortunately, AngularJs rewrite "example.com#panel" as "example.com#/panel" thus breaking the original implementation.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user