Skip to content

Commit 28d68bf

Browse files
authored
fix: Avoid showing top-level platform in search (#13072)
1 parent 469f503 commit 28d68bf

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/components/platformFilter/client.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ export function PlatformFilterClient({platforms}: {platforms: Platform[]}) {
7070
return matches_;
7171
}, [filter, platformsAndGuides]);
7272

73+
const matchKeys = useMemo(() => {
74+
return matches.map(x => x.key);
75+
}, [matches]);
76+
7377
const platformColumns: Platform[][] = splitToChunks(
7478
3,
7579
uniqByReference(matches.map(x => (x.type === 'platform' ? x : x.platform))).map(p => {
@@ -161,6 +165,7 @@ export function PlatformFilterClient({platforms}: {platforms: Platform[]}) {
161165
<PlatformWithGuides
162166
key={platform.key}
163167
platform={platform}
168+
matchKeys={matchKeys}
164169
// force expand if the filter is long enough to have few results
165170
forceExpand={filter.length >= 2}
166171
/>
@@ -180,11 +185,19 @@ export function PlatformFilterClient({platforms}: {platforms: Platform[]}) {
180185
function PlatformWithGuides({
181186
platform,
182187
forceExpand,
188+
matchKeys,
183189
}: {
184190
forceExpand: boolean;
191+
matchKeys: string[];
185192
platform: Platform;
186193
}) {
187194
const [expanded, setExpanded] = useState(false);
195+
196+
const guides = useMemo(() => {
197+
const showPlatformInContent = matchKeys.includes(platform.key);
198+
return showPlatformInContent ? [platform, ...platform.guides] : platform.guides;
199+
}, [matchKeys, platform]);
200+
188201
return (
189202
<Collapsible.Root
190203
className={styles.CollapsibleRoot}
@@ -217,7 +230,7 @@ function PlatformWithGuides({
217230
// scrollable if there are more than 8 (arbitrary limit) guides
218231
data-scrollable={platform.guides.length >= 8 || platform.integrations.length >= 8}
219232
>
220-
{[platform, ...platform.guides].map((guide, i) => (
233+
{guides.map((guide, i) => (
221234
<Link
222235
href={guide.url}
223236
style={{textDecoration: 'none', color: 'var(--foreground) !important'}}

0 commit comments

Comments
 (0)