Skip to content

Commit

Permalink
Fixed EuiBadge iconOnClick makes badge text clickable (#3392)
Browse files Browse the repository at this point in the history
* Fixed badge text clickable when iconOnClick is provided

* Updated tests

* Added cl
  • Loading branch information
ashikmeerankutty authored Apr 28, 2020
1 parent bf5b98a commit c9ae5a0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
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

0 comments on commit c9ae5a0

Please sign in to comment.