Skip to content

Commit

Permalink
wrapping long tags on agent details page
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Jul 19, 2022
1 parent 568e631 commit 430b5dc
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
import { EuiToolTip } from '@elastic/eui';
import { take } from 'lodash';
import React from 'react';
import styled from 'styled-components';

import { truncateTag, MAX_TAG_DISPLAY_LENGTH } from '../utils';

const Wrapped = styled.div`
.wrappedText {
white-space: pre-wrap;
}
`;

interface Props {
tags: string[];
}
Expand All @@ -22,13 +29,16 @@ export const Tags: React.FunctionComponent<Props> = ({ tags }) => {
return (
<>
{tags.length > MAX_TAGS_TO_DISPLAY ? (
<>
<EuiToolTip content={<span data-test-subj="agentTagsTooltip">{tags.join(', ')}</span>}>
<Wrapped>
<EuiToolTip
anchorClassName={'wrappedText'}
content={<span data-test-subj="agentTagsTooltip">{tags.join(', ')}</span>}
>
<span data-test-subj="agentTags">
{take(tags, 3).map(truncateTag).join(', ')} + {tags.length - MAX_TAGS_TO_DISPLAY} more
</span>
</EuiToolTip>
</>
</Wrapped>
) : (
<span data-test-subj="agentTags">
{tags.map((tag, index) => (
Expand Down

0 comments on commit 430b5dc

Please sign in to comment.