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 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- Fixed EuiBasicTable proptypes of itemId ([#3133](https://github.com/elastic/eui/pull/3133))
- Updated `EuiSuperDatePicker` to inherit the selected value in quick select ([#3105](https://github.com/elastic/eui/pull/3105))
- Pass title and aria attributes to `EuiToken`'s icon element ([#3195](https://github.com/elastic/eui/pull/3195))

### Feature: EuiCollapsibleNav ([#3019](https://github.com/elastic/eui/pull/3019))

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;
/**
* What would typically be the icon's title. Required for accessibility.
cchaos marked this conversation as resolved.
Show resolved Hide resolved
*/
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>
);
};