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] Respect isDisabled on extraAction config #4359

Merged
merged 4 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -102,6 +102,34 @@ exports[`EuiListGroupItem props color text is rendered 1`] = `
</li>
`;

exports[`EuiListGroupItem props extraAction can be disabled 1`] = `
<li
class="euiListGroupItem euiListGroupItem--medium euiListGroupItem-hasExtraAction"
>
<span
class="euiListGroupItem__text"
>
<span
class="euiListGroupItem__label"
title="Label"
>
Label
</span>
</span>
<button
class="euiButtonIcon euiButtonIcon--primary euiListGroupItem__extraAction"
disabled=""
type="button"
>
<span
aria-hidden="true"
class="euiButtonIcon__icon"
data-euiicon-type="empty"
/>
</button>
</li>
`;

exports[`EuiListGroupItem props extraAction is rendered 1`] = `
<li
class="euiListGroupItem euiListGroupItem--medium euiListGroupItem-hasExtraAction"
Expand Down
14 changes: 14 additions & 0 deletions src/components/list_group/list_group_item.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ describe('EuiListGroupItem', () => {

expect(component).toMatchSnapshot();
});

test('can be disabled', () => {
const component = render(
<EuiListGroupItem
label="Label"
extraAction={{
iconType: 'empty',
isDisabled: true,
}}
/>
);

expect(component).toMatchSnapshot();
});
});

describe('href', () => {
Expand Down
10 changes: 8 additions & 2 deletions src/components/list_group/list_group_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,13 @@ export const EuiListGroupItem: FunctionComponent<EuiListGroupItemProps> = ({
let extraActionNode;

if (extraAction) {
const { iconType, alwaysShow, className, ...rest } = extraAction;
const {
iconType,
alwaysShow,
className,
isDisabled: actionIsDisabled,
...rest
} = extraAction;

const extraActionClasses = classNames(
'euiListGroupItem__extraAction',
Expand All @@ -211,7 +217,7 @@ export const EuiListGroupItem: FunctionComponent<EuiListGroupItemProps> = ({
className={extraActionClasses}
iconType={iconType}
{...rest}
disabled={isDisabled}
disabled={isDisabled || actionIsDisabled}
/>
);
}
Expand Down