Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiListGroupItem] Add Tooltip text prop #6186

Merged
merged 5 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src-docs/src/views/list_group/list_group_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,18 @@ export const ListGroupExample = {
},
],
text: (
<p>
Optional props <EuiCode>showToolTip</EuiCode> and{' '}
<EuiCode>wrapLines</EuiCode> can be used to augment the display of
list items. Use these when lists are inside small containers where it
is likely that the content will be truncated.
</p>
<>
<p>
Similarly, <EuiCode>toolTipText</EuiCode> can be used to provide
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thompsongl I think, here the lines removed/edited incorrectly by you. Maybe you meant to just improve what I added

What I added,

         <p>
            <EuiCode>toolTipText</EuiCode> can
            be also used to provide tooltip text. By default, the tooltip will
            have the text same as <EuiCode>label</EuiCode> text.
          </p>

Your suggestion,

         <p>
            Similarly, ...rest is same as above ...
          </p>

Mistakenly you removed the wrong block an duplicated the same paragraph. I know the PR is already merged but we will need to fix this if it's not intentional right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep you're right. 🤦‍♂️ I'll fix it.

Copy link
Contributor

Choose a reason for hiding this comment

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

tooltip text. By default, the tooltip will have the text same as{' '}
<EuiCode>label</EuiCode> text.
</p>
<p>
In addtion to that, optional prop <EuiCode>toolTipText</EuiCode> can
be also used to provide tooltip text. By default, the tooltip will
have the text same as <EuiCode>label</EuiCode> text.
</p>
</>
),
demo: <ListGroupExtra />,
snippet: `<EuiListGroup showToolTips>
Expand Down
6 changes: 5 additions & 1 deletion src-docs/src/views/list_group/list_group_extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { EuiListGroup, EuiListGroupItem } from '../../../../src/components';

export default () => (
<EuiListGroup showToolTips>
<EuiListGroupItem onClick={() => {}} label="First item" />
<EuiListGroupItem
onClick={() => {}}
label="First item"
toolTipText="This is tooltip text"
/>

<EuiListGroupItem onClick={() => {}} label="Second item" />

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 @@ -137,6 +137,12 @@ export type EuiListGroupItemProps = CommonProps &
* instances where the item content is rendered as a `button`
*/
buttonRef?: React.Ref<HTMLButtonElement>;

/**
* Text to be displayed in the tooltip when `showToolTip` is true.
* By default the text will be same as the label text.
*/
toolTipText?: string;
};

export const EuiListGroupItem: FunctionComponent<EuiListGroupItemProps> = ({
Expand All @@ -157,6 +163,7 @@ export const EuiListGroupItem: FunctionComponent<EuiListGroupItemProps> = ({
showToolTip = false,
wrapText,
buttonRef,
toolTipText,
...rest
}) => {
const isHrefValid = !href || validateHref(href);
Expand Down Expand Up @@ -291,7 +298,7 @@ export const EuiListGroupItem: FunctionComponent<EuiListGroupItemProps> = ({
<li className={classes}>
<EuiToolTip
anchorClassName="euiListGroupItem__tooltip"
content={label}
content={toolTipText ?? label}
position="right"
delay="long"
>
Expand Down
1 change: 1 addition & 0 deletions upcoming_changelogs/6186.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added `tooltipText` as an optional prop on `EuiListGroupItem`