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

Pass title and aria attributes to EuiToken's icon element #3195

Merged
merged 6 commits into from
Mar 30, 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 @@ -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>
);
};