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] Render extraAction button when showToolTip is true #7159

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,6 @@ exports[`EuiListGroupItem props color text is rendered 1`] = `
</li>
`;

exports[`EuiListGroupItem props extraAction can be disabled 1`] = `
<li
class="euiListGroupItem emotion-euiListGroupItem-m"
>
<span
class="euiListGroupItem__text emotion-euiListGroupItem__inner-m-text"
>
<span
class="euiListGroupItem__label emotion-euiListGroupItem__label-truncate"
title="Label"
>
Label
</span>
</span>
<button
aria-label="label"
class="euiButtonIcon euiListGroupItemExtraAction emotion-euiButtonIcon-xs-empty-disabled-isDisabled-euiListGroupItemExtraAction-hoverStyles"
disabled=""
type="button"
>
<span
aria-hidden="true"
class="euiButtonIcon__icon"
color="inherit"
data-euiicon-type="empty"
/>
</button>
</li>
`;

exports[`EuiListGroupItem props extraAction is rendered 1`] = `
<li
class="euiListGroupItem emotion-euiListGroupItem-m"
Expand Down
22 changes: 20 additions & 2 deletions src/components/list_group/list_group_item.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,37 @@ describe('EuiListGroupItem', () => {
expect(container.firstChild).toMatchSnapshot();
});

test('is rendered with showToolTip', () => {
const { getByTestSubject } = render(
<EuiListGroupItem
label="Label"
showToolTip
extraAction={{
iconType: 'empty',
alwaysShow: true,
'aria-label': 'label',
'data-test-subj': 'extraAction',
}}
/>
);

expect(getByTestSubject('extraAction')).toBeInTheDocument();
});

test('can be disabled', () => {
const { container } = render(
const { getByTestSubject } = render(
<EuiListGroupItem
label="Label"
extraAction={{
iconType: 'empty',
isDisabled: true,
'aria-label': 'label',
'data-test-subj': 'extraAction',
}}
/>
);

expect(container.firstChild).toMatchSnapshot();
expect(getByTestSubject('extraAction')).toBeDisabled();
});
});

Expand Down
5 changes: 4 additions & 1 deletion src/components/list_group/list_group_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ export const EuiListGroupItem: FunctionComponent<EuiListGroupItemProps> = ({
anchorClassName={anchorClasses}
anchorProps={anchorPropsAndCss}
>
{itemContent}
<>
{itemContent}
{extraActionNode}
</>
</EuiToolTip>
</li>
);
Expand Down
3 changes: 3 additions & 0 deletions upcoming_changelogs/7159.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Fixed `EuiListGroupItem` to correctly render the `extraAction` button when `showToolTip` is also passed
Loading