Skip to content

Commit

Permalink
fix(components/TagsDiv): move tags to extra if their number exceeds m…
Browse files Browse the repository at this point in the history
…ax by 1+ (#682)
  • Loading branch information
SunsetTechuila authored Jan 25, 2024
1 parent 5564b64 commit 92c6f44
Showing 1 changed file with 8 additions and 8 deletions.
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

0 comments on commit 92c6f44

Please sign in to comment.