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

Fixed EuiBadge iconOnClick makes badge text clickable #3392

Merged
merged 3 commits into from
Apr 28, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

**Bug Fixes**

- Fixed `EuiBadge` `iconOnClick` props makes badge text clickable ([#3392](https://github.com/elastic/eui/pull/3392))
- Added `id` requirement if `label` is used in `EuiRadio` ([#3382](https://github.com/elastic/eui/pull/3382))
- Fixed z-index issue in `EuiDatePicker` where it's popover would sit beneath other DOM siblings that had z-index applied ([#3376](https://github.com/elastic/eui/pull/3376))
- Added `download` glyph to `EuiIcon` ([#3364](https://github.com/elastic/eui/pull/3364))
Expand Down
10 changes: 5 additions & 5 deletions src/components/badge/__snapshots__/badge.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,19 @@ exports[`EuiBadge is rendered with iconOnClick and onClick provided 1`] = `

exports[`EuiBadge is rendered with iconOnClick provided 1`] = `
<span
aria-label="aria-label"
class="euiBadge euiBadge--iconLeft testClass1 testClass2"
data-test-subj="test subject string"
style="background-color:#d3dae6;color:#000"
>
<span
class="euiBadge__content"
>
<button
aria-label="aria-label"
class="euiBadge__childButton"
data-test-subj="test subject string"
<span
class="euiBadge__text"
>
Content
</button>
</span>
</span>
</span>
`;
Expand Down
18 changes: 17 additions & 1 deletion src/components/badge/badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export const EuiBadge: FunctionComponent<EuiBadgeProps> = ({
}

if (iconOnClick) {
return (
return onClick || href ? (
<span className={classes} style={optionalCustomStyles}>
<span className="euiBadge__content">
<EuiInnerText>
Expand All @@ -289,6 +289,22 @@ export const EuiBadge: FunctionComponent<EuiBadgeProps> = ({
{optionalIcon}
</span>
</span>
) : (
<EuiInnerText>
{(ref, innerText) => (
<span
className={classes}
style={optionalCustomStyles}
ref={ref}
title={innerText}
{...rest}>
<span className="euiBadge__content">
<span className="euiBadge__text">{children}</span>
{optionalIcon}
</span>
</span>
)}
</EuiInnerText>
);
} else if (onClick || href) {
return (
Expand Down