mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix Navigation.navigate to work with fragments (#2890)
This commit is contained in:
parent
8b352f6c6b
commit
db54a658a2
@ -20,17 +20,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { LocationDescriptor } from "history";
|
import type { LocationDescriptor } from "history";
|
||||||
|
import { createPath } from "history";
|
||||||
import { matchPath, RouteProps } from "react-router";
|
import { matchPath, RouteProps } from "react-router";
|
||||||
import { PageParam, PageParamInit } from "./page-param";
|
import { PageParam, PageParamInit } from "./page-param";
|
||||||
import { clusterViewRoute, IClusterViewRouteParams } from "../components/cluster-manager/cluster-view.route";
|
import { clusterViewRoute, IClusterViewRouteParams } from "../components/cluster-manager/cluster-view.route";
|
||||||
import { navigation } from "./history";
|
import { navigation } from "./history";
|
||||||
|
|
||||||
export function navigate(location: LocationDescriptor) {
|
export function navigate(location: LocationDescriptor) {
|
||||||
const currentLocation = navigation.location.pathname;
|
const currentLocation = createPath(navigation.location);
|
||||||
|
|
||||||
navigation.push(location);
|
navigation.push(location);
|
||||||
|
|
||||||
if (currentLocation === navigation.location.pathname) {
|
const newLocation = createPath(navigation.location);
|
||||||
|
|
||||||
|
if (currentLocation === newLocation) {
|
||||||
navigation.goBack(); // prevent sequences of same url in history
|
navigation.goBack(); // prevent sequences of same url in history
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user