Skip to content

fix: Update sorting order for guides on platform filter #11547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/platformFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ export function PlatformFilter({platforms}: {platforms: Platform[]}) {
uniqByReference(matches.map(x => (x.type === 'platform' ? x : x.platform))).map(p => {
return {
...p,
guides: p.guides.filter(g => matches.some(m => m.key === g.key)),
guides: matches
.filter(m => m.type === 'guide' && m.platform.key === p.key)
.map(m => p.guides.find(g => g.key === m.key)!)
.filter(Boolean),
integrations: p.integrations.filter(i => matches.some(m => m.key === i.key)),
};
})
);

return (
<div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 py-8 md:items-end">
Expand Down
12 changes: 9 additions & 3 deletions src/components/platformSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,15 @@ export function PlatformSelector({
platform={{
...platform,
// only keep guides that are in the matches list
guides: platform.guides.filter(g =>
matches.some(m => m.key === g.key)
),
guides: platform.guides
.filter(g =>
matches.some(m => m.key === g.key && m.type === 'guide')
)
.sort((a, b) => {
const indexA = matches.findIndex(m => m.key === a.key);
const indexB = matches.findIndex(m => m.key === b.key);
return indexA - indexB;
}),

integrations: platform.integrations.filter(i =>
matches.some(m => m.key === i.key)
Expand Down
Loading