1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-04 13:48:56 +02:00

fix: truncate

This commit is contained in:
FredrikOseberg 2025-03-19 23:02:02 +01:00
parent 613b77819f
commit 87ebc0dd18
No known key found for this signature in database
GPG Key ID: 282FD8A6D8F9BCF0

View File

@ -157,10 +157,11 @@ const ArchivedFeatureName: FC<{
); );
}; };
const RestTags: FC<{ tags: ITag[]; onClick: (tag: string) => void }> = ({ const RestTags: FC<{
tags, tags: ITag[];
onClick, onClick: (tag: string) => void;
}) => { isTagTypeColorEnabled: boolean;
}> = ({ tags, onClick, isTagTypeColorEnabled }) => {
return ( return (
<HtmlTooltip <HtmlTooltip
title={tags.map((tag) => ( title={tags.map((tag) => (
@ -169,7 +170,11 @@ const RestTags: FC<{ tags: ITag[]; onClick: (tag: string) => void }> = ({
onClick={() => onClick(`${tag.type}:${tag.value}`)} onClick={() => onClick(`${tag.type}:${tag.value}`)}
key={`${tag.type}:${tag.value}`} key={`${tag.type}:${tag.value}`}
> >
{`${tag.type}:${tag.value}`} {isTagTypeColorEnabled ? (
<Tag tag={tag} />
) : (
`${tag.type}:${tag.value}`
)}
</Box> </Box>
))} ))}
> >
@ -208,12 +213,26 @@ const Tags: FC<{
const isOverflowing = tagFullText.length > 30; const isOverflowing = tagFullText.length > 30;
if (isTagTypeColorEnabled) { if (isTagTypeColorEnabled) {
// Create a tag object with truncated display value but keeping original values
const displayTag = {
...tag,
displayValue: isOverflowing
? `${tag.value.substring(0, Math.max(0, 30 - tag.type.length - 1))}...`
: tag.value,
};
const tagComponent = ( const tagComponent = (
<Box <Box
onClick={() => handleTagClick(tag)} onClick={() => handleTagClick(tag)}
sx={{ cursor: 'pointer' }} sx={{ cursor: 'pointer' }}
> >
<Tag tag={tag} /> <Tag
tag={{
type: tag.type,
value: displayTag.displayValue,
color: tag.color,
}}
/>
</Box> </Box>
); );
@ -253,7 +272,13 @@ const Tags: FC<{
{tag3 && renderTag(tag3)} {tag3 && renderTag(tag3)}
<ConditionallyRender <ConditionallyRender
condition={restTags.length > 0} condition={restTags.length > 0}
show={<RestTags tags={restTags} onClick={onClick} />} show={
<RestTags
tags={restTags}
onClick={onClick}
isTagTypeColorEnabled={isTagTypeColorEnabled}
/>
}
/> />
</TagsContainer> </TagsContainer>
); );