Skip to content

Commit 40f4bda

Browse files
authored
Keep platform selector in sync with pathname (#12049)
keep selected platform in sync with pathname upon back button click
1 parent 2084fa5 commit 40f4bda

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/components/platformSelector/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {Combobox, ComboboxItem, ComboboxList, ComboboxProvider} from '@ariakit/r
1212
import {CaretRightIcon, CaretSortIcon, MagnifyingGlassIcon} from '@radix-ui/react-icons';
1313
import * as RadixSelect from '@radix-ui/react-select';
1414
import {matchSorter} from 'match-sorter';
15-
import {usePathname} from 'next/navigation';
15+
import {usePathname, useRouter} from 'next/navigation';
1616

1717
import {PlatformIcon} from 'sentry-docs/components/platformIcon';
1818
import {Platform, PlatformGuide, PlatformIntegration} from 'sentry-docs/types';
@@ -90,13 +90,12 @@ export function PlatformSelector({
9090
return matches_;
9191
}, [searchValue, currentPlatformKey, platformsAndGuides]);
9292

93+
const router = useRouter();
9394
const onPlatformChange = (platformKey: string) => {
9495
const platform_ = platformsAndGuides.find(platform => platform.key === platformKey);
9596
if (platform_) {
9697
localStorage.setItem('active-platform', platform_.key);
97-
// feels wrong to use window.location here,
98-
// but router.push is not working on mobile for some reason
99-
window.location.href = platform_.url;
98+
router.push(platform_.url);
10099
}
101100
};
102101

0 commit comments

Comments
 (0)