Skip to content
Merged
4 changes: 4 additions & 0 deletions src-docs/src/views/list_group/list_group_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ export const ListGroupExample = {
tooltip text. By default, the tooltip will have the text same as the{' '}
<EuiCode>label</EuiCode>.
</p>
<p>
Use <EuiCode>toolTipProps</EuiCode> to customize tooltip placement,
title, and other behaviors.
</p>
</>
),
demo: <ListGroupExtra />,
Expand Down
17 changes: 15 additions & 2 deletions src-docs/src/views/list_group/list_group_extra.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import React from 'react';

import { EuiListGroup, EuiListGroupItem } from '../../../../src/components';
import {
EuiListGroup,
EuiListGroupItem,
EuiToolTipProps,
} from '../../../../src/components';

const myToolTipProps: EuiToolTipProps = {
children: <span />,
delay: 'regular',
id: '12345',
position: 'top',
title: 'Title of record',
};

export default () => (
<EuiListGroup showToolTips>
Expand All @@ -25,7 +37,8 @@ export default () => (
<EuiListGroupItem
onClick={() => {}}
wrapText
label="Fourth very, very long item with wrapping enabled that will not force truncation"
label="Fourth very long item with wrapping enabled, custom props, and will not force truncation."
toolTipProps={myToolTipProps}
/>
</EuiListGroup>
);
7 changes: 7 additions & 0 deletions src/components/list_group/list_group.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ const someListItems: EuiListGroupItemProps[] = [
onClick: (e) => {
console.log('Visualize clicked', e);
},
toolTipProps: {
children: <button />,
delay: 'regular',
id: '12345',
position: 'top',
title: 'Title of record',
},
},
{
label: 'Active link',
Expand Down
9 changes: 8 additions & 1 deletion src/components/list_group/list_group_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import React, {
import classNames from 'classnames';

import { EuiIcon, IconType, EuiIconProps } from '../icon';
import { EuiToolTip } from '../tool_tip';
import { EuiToolTip, EuiToolTipProps } from '../tool_tip';
import { useInnerText } from '../inner_text';
import { ExclusiveUnion, CommonProps } from '../common';
import {
Expand Down Expand Up @@ -144,6 +144,11 @@ export type EuiListGroupItemProps = CommonProps &
* By default the text will be same as the label text.
*/
toolTipText?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[not a change request, just me thinking out loud] I wonder if we should consider deprecating this prop in favor of telling consumers to use toolTipProps.content 🤔 Probably not since this is a nicer API, but wanted to throw that out there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lean toward keeping it. Agree with you it's a nice API and saves a few keystrokes if folks want to just add a custom string the tooltip than string plus N number more change.


/**
* Props can be passed to nested`EuiToolTip`.
*/
toolTipProps?: EuiToolTipProps;
};

export const EuiListGroupItem: FunctionComponent<EuiListGroupItemProps> = ({
Expand All @@ -166,6 +171,7 @@ export const EuiListGroupItem: FunctionComponent<EuiListGroupItemProps> = ({
wrapText,
buttonRef,
toolTipText,
toolTipProps,
...rest
}) => {
const isClickable = !!(href || onClick);
Expand Down Expand Up @@ -330,6 +336,7 @@ export const EuiListGroupItem: FunctionComponent<EuiListGroupItemProps> = ({
content={toolTipText ?? label}
position="right"
delay="long"
{...toolTipProps}
>
{itemContent}
</EuiToolTip>
Expand Down
1 change: 1 addition & 0 deletions upcoming_changelogs/7018.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added `toolTipProps` to `EuiListGroupItem` to customize nested tooltips.