Skip to content

Commit 4d969df

Browse files
[One Discover] [Logs UX] Show full title tooltips on resources badges and only truncate titles in summary column (#241557)
- Make the truncation configurable so that resource badges are rendered without truncation when rendered as individual columns (for Summary column, they'll truncate). - Show the hover tooltip with full titles, always. Before https://github.com/user-attachments/assets/1d296649-9967-4be8-b2e3-fcc738e46244 After https://github.com/user-attachments/assets/ebca3b16-9cc1-4f71-b9a2-b02902fd1ac9 Co-authored-by: Elastic Machine <[email protected]>
1 parent 37628e1 commit 4d969df

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/platform/packages/shared/kbn-discover-contextual-components/src/data_types/logs/components/cell_actions_popover.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
filterOutText,
3939
openCellActionPopoverAriaText,
4040
} from './translations';
41-
import { truncateAndPreserveHighlightTags } from './utils';
41+
import { truncateAndPreserveHighlightTags, extractTextAndMarkTags } from './utils';
4242

4343
interface CellActionsPopoverProps {
4444
onFilter?: DocViewFilterFn;
@@ -178,6 +178,7 @@ export interface FieldBadgeWithActionsProps
178178
> {
179179
icon?: EuiBadgeProps['iconType'];
180180
color?: string;
181+
truncateTitle?: boolean;
181182
}
182183

183184
interface FieldBadgeWithActionsDependencies {
@@ -197,9 +198,13 @@ export function FieldBadgeWithActions({
197198
value,
198199
rawValue,
199200
color = 'hollow',
201+
truncateTitle = false,
200202
}: FieldBadgeWithActionsPropsAndDependencies) {
201203
const MAX_LENGTH = 20;
202204

205+
const displayValue = truncateTitle ? truncateAndPreserveHighlightTags(value, MAX_LENGTH) : value;
206+
const titleText = extractTextAndMarkTags(value).cleanText;
207+
203208
return (
204209
<CellActionsPopover
205210
onFilter={onFilter}
@@ -209,11 +214,17 @@ export function FieldBadgeWithActions({
209214
rawValue={rawValue}
210215
renderValue={renderValue}
211216
renderPopoverTrigger={({ popoverTriggerProps }) => (
212-
<EuiBadge {...popoverTriggerProps} color={color} iconType={icon} iconSide="left">
217+
<EuiBadge
218+
{...popoverTriggerProps}
219+
color={color}
220+
iconType={icon}
221+
iconSide="left"
222+
title={titleText}
223+
>
213224
<span
214225
// eslint-disable-next-line react/no-danger
215226
dangerouslySetInnerHTML={{
216-
__html: truncateAndPreserveHighlightTags(value, MAX_LENGTH),
227+
__html: displayValue,
217228
}}
218229
/>
219230
</EuiBadge>

src/platform/packages/shared/kbn-discover-contextual-components/src/data_types/logs/components/summary_column/resource.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const Resource = ({ fields, limited = false, onFilter, ...props }: Resour
3838
value={value}
3939
icon={Icon}
4040
onFilter={onFilter}
41+
truncateTitle={true}
4142
/>
4243
))}
4344
{extraFieldsCount > 0 && (

src/platform/packages/shared/kbn-discover-contextual-components/src/data_types/logs/components/utils/truncate_preserve_highlight_tags.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
function extractTextAndMarkTags(html: string) {
10+
export function extractTextAndMarkTags(html: string) {
1111
const markTags: string[] = [];
1212
const cleanText = html.replace(/<\/?mark[^>]*>/g, (match) => {
1313
markTags.push(match);

0 commit comments

Comments
 (0)