Skip to content

Commit 8637559

Browse files
Fix: PlatformSelector key collision and add unique key to default guide
Co-authored-by: shannon.anahata <[email protected]>
1 parent 49b42e3 commit 8637559

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/components/platformSelector/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,14 @@ export function PlatformSelector({
8484
});
8585
// Radix Select does not work if we don't render the selected item, so we
8686
// make sure to include it in the list of matches.
87-
// Match by both key AND type to handle key collisions (e.g., javascript platform vs guide)
8887
const selectedPlatform = platformsAndGuides.find(
89-
lang => lang.key === currentPlatformKey && lang.type === currentPlatform?.type
88+
lang => lang.key === currentPlatformKey
9089
);
9190
if (selectedPlatform && !matches_.includes(selectedPlatform)) {
9291
matches_.push(selectedPlatform);
9392
}
9493
return matches_;
95-
}, [searchValue, currentPlatformKey, platformsAndGuides, currentPlatform?.type]);
94+
}, [searchValue, currentPlatformKey, platformsAndGuides]);
9695

9796
const router = useRouter();
9897
const onPlatformChange = (platformKey: string) => {

src/docTree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ function extractGuides(platformNode: DocNode): PlatformGuide[] {
376376
const defaultGuide = platformNode.frontmatter.platformTitle
377377
? {
378378
...nodeToGuide(platformNode.slug, platformNode),
379-
key: platformNode.slug,
379+
key: `${platformNode.slug}-platform`,
380380
}
381381
: undefined;
382382

0 commit comments

Comments
 (0)