Skip to content

Commit 92c6f44

Browse files
fix(components/TagsDiv): move tags to extra if their number exceeds max by 1+ (#682)
1 parent 5564b64 commit 92c6f44

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/components/Card/TagsDiv.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ const TagsDiv = (props: {
4040
return accum;
4141
}, []);
4242
};
43-
44-
const baseTags = props.tags
45-
// Sort tags so that externalJS and archived tags come first
46-
.sort((a) =>
47-
a === t("grid.externalJS") || a === t("grid.archived") ? -1 : 1,
48-
)
49-
.slice(0, MAX_TAGS);
50-
const extraTags = props.tags.slice(MAX_TAGS);
43+
// Sort tags so that externalJS and archived tags come first
44+
let baseTags = props.tags.sort((a) => a === t("grid.externalJS") || a === t("grid.archived") ? -1 : 1);
45+
let extraTags: string[] = [];
46+
// If there are more than one extra tags, slice them and add an expand button
47+
if (baseTags.length - MAX_TAGS > 1) {
48+
extraTags = props.tags.slice(MAX_TAGS);
49+
baseTags = baseTags.slice(0, MAX_TAGS);
50+
}
5151

5252
// Render the tags list and add expand button if there are more tags
5353
return (

0 commit comments

Comments
 (0)