Skip to content

Commit

Permalink
Pass title and aria attributes to EuiToken's icon element (#3195)
Browse files Browse the repository at this point in the history
  • Loading branch information
mridulgogia authored Mar 30, 2020
1 parent 88f1041 commit f45e950
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Improved `htmlIdGenerator` when supplying both `prefix` and `suffix` ([#3076](https://github.com/elastic/eui/pull/3076))
- Updated pagination prop descriptions for `EuiInMemoryTable` ([#3142](https://github.com/elastic/eui/pull/3142))
- Added `title` and `aria` attributes to `EuiToken`'s icon element ([#3195](https://github.com/elastic/eui/pull/3195))

## [`22.2.0`](https://github.com/elastic/eui/tree/v22.2.0)

Expand Down
2 changes: 1 addition & 1 deletion src/components/token/__snapshots__/token.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

exports[`EuiToken is rendered 1`] = `
<span
aria-label="aria-label"
class="euiToken euiToken--gray euiToken--circle euiToken--light euiToken--small testClass1 testClass2"
data-test-subj="test subject string"
>
<div
aria-label="aria-label"
data-euiicon-type="dot"
/>
</span>
Expand Down
20 changes: 19 additions & 1 deletion src/components/token/token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ export interface TokenProps {
* Size of the token
*/
size?: TokenSize;
/**
* The icon's title. Required for accessibility
*/
title?: string;
'aria-label'?: string;
'aria-labelledby'?: string;
'aria-describedby'?: string;
}

export type EuiTokenProps = CommonProps &
Expand All @@ -103,6 +110,10 @@ export const EuiToken: FunctionComponent<EuiTokenProps> = ({
size = 's',
style = {},
className,
title,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledby,
'aria-describedby': ariaDescribedby,
...rest
}) => {
// Set the icon size to the same as the passed size
Expand Down Expand Up @@ -171,7 +182,14 @@ export const EuiToken: FunctionComponent<EuiTokenProps> = ({

return (
<span className={classes} style={style} {...rest}>
<EuiIcon type={iconType} size={finalSize} />
<EuiIcon
type={iconType}
size={finalSize}
title={title}
aria-label={ariaLabel}
aria-labelledby={ariaLabelledby}
aria-describedby={ariaDescribedby}
/>
</span>
);
};

0 comments on commit f45e950

Please sign in to comment.