diff --git a/src/components/Card/TagsDiv.tsx b/src/components/Card/TagsDiv.tsx index 495c1d61..15f004fc 100644 --- a/src/components/Card/TagsDiv.tsx +++ b/src/components/Card/TagsDiv.tsx @@ -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 (