@the-portland-company/shell 0.76.8 → 0.76.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -911,9 +911,15 @@ function TokenChromeStateProvider({
911
911
  })),
912
912
  [tokenOrg.orgs, fetchedOrgs]
913
913
  );
914
- const [urlSelector] = useState(
914
+ const [urlSelector, setUrlSelector] = useState(
915
915
  () => typeof window === "undefined" ? null : readOrgSelectorFromUrl(window.location.search)
916
916
  );
917
+ useEffect(() => {
918
+ if (typeof window === "undefined") return;
919
+ const onLocationChange = () => setUrlSelector(readOrgSelectorFromUrl(window.location.search));
920
+ window.addEventListener("popstate", onLocationChange);
921
+ return () => window.removeEventListener("popstate", onLocationChange);
922
+ }, []);
917
923
  const overrideOrg = useMemo(
918
924
  () => urlSelector ? matchOrgSelector(urlSelector, orgs)?.id ?? null : null,
919
925
  [urlSelector, orgs]
@@ -939,6 +945,7 @@ function TokenChromeStateProvider({
939
945
  void (async () => {
940
946
  try {
941
947
  const claims = await switchActiveOrg(id, { authBaseUrl: current.authBaseUrl });
948
+ setUrlSelector(null);
942
949
  try {
943
950
  const url = new URL(window.location.href);
944
951
  url.searchParams.delete(ACTIVE_ORG_QUERY_PARAM);