-
({ ...location, pathname: "/" })}>
+
({ ...pickCluster(location), pathname: "/" })}
+ >
diff --git a/explorer/src/components/TabbedPage.tsx b/explorer/src/components/TabbedPage.tsx
index 820bf8294f..feb3978786 100644
--- a/explorer/src/components/TabbedPage.tsx
+++ b/explorer/src/components/TabbedPage.tsx
@@ -2,6 +2,7 @@ import React from "react";
import { Link } from "react-router-dom";
import { useClusterModal } from "providers/cluster";
import ClusterStatusButton from "components/ClusterStatusButton";
+import { pickCluster } from "utils/url";
export type Tab = "Transactions" | "Accounts" | "Supply";
@@ -64,7 +65,7 @@ function NavLink({
return (
({ ...location, pathname: href })}
+ to={location => ({ ...pickCluster(location), pathname: href })}
className={classes}
>
{tab}
diff --git a/explorer/src/utils/url.ts b/explorer/src/utils/url.ts
index 207d0ce646..26cacf1a99 100644
--- a/explorer/src/utils/url.ts
+++ b/explorer/src/utils/url.ts
@@ -1,9 +1,26 @@
import { useLocation } from "react-router-dom";
+import { Location } from "history";
export function useQuery() {
return new URLSearchParams(useLocation().search);
}
+export function pickCluster(location: Location): Location {
+ const cluster = new URLSearchParams(location.search).get("cluster");
+
+ let search = "";
+ if (cluster) {
+ const params = new URLSearchParams();
+ params.set("cluster", cluster);
+ search = params.toString();
+ }
+
+ return {
+ ...location,
+ search
+ };
+}
+
export function findGetParameter(parameterName: string): string | null {
let result = null,
tmp = [];