Skip to content

Commit a23b73f

Browse files
authored
truncate tag label so that action button remains visible (#136643)
1 parent d5fe8e5 commit a23b73f

File tree

1 file changed

+11
-2
lines changed
  • x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components

1 file changed

+11
-2
lines changed

x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/tags_add_remove.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import React, { Fragment, useCallback, useEffect, useState } from 'react';
99
import { difference } from 'lodash';
10+
import styled from 'styled-components';
1011
import type { EuiSelectableOption } from '@elastic/eui';
1112
import {
1213
EuiButtonEmpty,
@@ -26,6 +27,13 @@ import { sanitizeTag } from '../utils';
2627

2728
import { TagOptions } from './tag_options';
2829

30+
const TruncatedEuiHighlight = styled(EuiHighlight)`
31+
width: 120px;
32+
white-space: nowrap;
33+
overflow: hidden;
34+
text-overflow: ellipsis;
35+
`;
36+
2937
interface Props {
3038
agentId?: string;
3139
agents?: string[] | string;
@@ -95,11 +103,12 @@ export const TagsAddRemove: React.FC<Props> = ({
95103
const renderOption = (option: EuiSelectableOption<any>, search: string) => {
96104
return (
97105
<EuiFlexGroup
106+
gutterSize={'s'}
98107
onMouseEnter={() => setIsTagHovered({ ...isTagHovered, [option.label]: true })}
99108
onMouseLeave={() => setIsTagHovered({ ...isTagHovered, [option.label]: false })}
100109
>
101110
<EuiFlexItem>
102-
<EuiHighlight
111+
<TruncatedEuiHighlight
103112
search={search}
104113
onClick={() => {
105114
const tagsToAdd = option.checked === 'on' ? [] : [option.label];
@@ -108,7 +117,7 @@ export const TagsAddRemove: React.FC<Props> = ({
108117
}}
109118
>
110119
{option.label}
111-
</EuiHighlight>
120+
</TruncatedEuiHighlight>
112121
</EuiFlexItem>
113122
<EuiFlexItem grow={false}>
114123
<TagOptions

0 commit comments

Comments
 (0)