Skip to content
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

fix(components/TagsDiv): move tags to extra if their number exceeds max by 1+ #682

Merged
merged 1 commit into from
Jan 25, 2024
Merged
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
16 changes: 8 additions & 8 deletions src/components/Card/TagsDiv.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ const TagsDiv = (props: {
return accum;
}, []);
};

const baseTags = props.tags
// Sort tags so that externalJS and archived tags come first
.sort((a) =>
a === t("grid.externalJS") || a === t("grid.archived") ? -1 : 1,
)
.slice(0, MAX_TAGS);
const extraTags = props.tags.slice(MAX_TAGS);
// Sort tags so that externalJS and archived tags come first
let baseTags = props.tags.sort((a) => a === t("grid.externalJS") || a === t("grid.archived") ? -1 : 1);
let extraTags: string[] = [];
// If there are more than one extra tags, slice them and add an expand button
if (baseTags.length - MAX_TAGS > 1) {
extraTags = props.tags.slice(MAX_TAGS);
baseTags = baseTags.slice(0, MAX_TAGS);
}

// Render the tags list and add expand button if there are more tags
return (
Expand Down
Loading