Skip to content

Commit 12b6f30

Browse files
authored
fix: Update sorting order for guides on platform filter (#11547)
1 parent 53c5a63 commit 12b6f30

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/components/platformFilter/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ export function PlatformFilter({platforms}: {platforms: Platform[]}) {
3838
uniqByReference(matches.map(x => (x.type === 'platform' ? x : x.platform))).map(p => {
3939
return {
4040
...p,
41-
guides: p.guides.filter(g => matches.some(m => m.key === g.key)),
41+
guides: matches
42+
.filter(m => m.type === 'guide' && m.platform.key === p.key)
43+
.map(m => p.guides.find(g => g.key === m.key)!)
44+
.filter(Boolean),
4245
integrations: p.integrations.filter(i => matches.some(m => m.key === i.key)),
4346
};
4447
})
4548
);
49+
4650
return (
4751
<div>
4852
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 py-8 md:items-end">

src/components/platformSelector/index.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,15 @@ export function PlatformSelector({
195195
platform={{
196196
...platform,
197197
// only keep guides that are in the matches list
198-
guides: platform.guides.filter(g =>
199-
matches.some(m => m.key === g.key)
200-
),
198+
guides: platform.guides
199+
.filter(g =>
200+
matches.some(m => m.key === g.key && m.type === 'guide')
201+
)
202+
.sort((a, b) => {
203+
const indexA = matches.findIndex(m => m.key === a.key);
204+
const indexB = matches.findIndex(m => m.key === b.key);
205+
return indexA - indexB;
206+
}),
201207

202208
integrations: platform.integrations.filter(i =>
203209
matches.some(m => m.key === i.key)

0 commit comments

Comments
 (0)