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

[EuiAvatar] Adding conditionalrole attribute to EuiAvatar container DIV #5423

Merged
merged 3 commits into from
Nov 30, 2021
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 @@ -6,6 +6,7 @@
**Bug fixes**

- Fixed an `EuiCodeBlock` bug where empty code blocks could be copyable ([#5421](https://github.com/elastic/eui/pull/5421))
- Fixed an accessibility issue in `EuiAvatar` by adding a meaningful role ([#5423](https://github.com/elastic/eui/pull/5423))

## [`41.3.0`](https://github.com/elastic/eui/tree/v41.3.0)

Expand Down
19 changes: 18 additions & 1 deletion src/components/avatar/__snapshots__/avatar.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`EuiAvatar allows a name composed entirely of whitespace 1`] = `
aria-label="aria-label"
class="euiAvatar euiAvatar--m euiAvatar--user testClass1 testClass2"
data-test-subj="test subject string"
role="img"
style="background-color:#ee789d;color:#000000"
title=" "
>
Expand All @@ -21,6 +22,7 @@ exports[`EuiAvatar is rendered 1`] = `
aria-label="aria-label"
class="euiAvatar euiAvatar--m euiAvatar--user testClass1 testClass2"
data-test-subj="test subject string"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -36,6 +38,7 @@ exports[`EuiAvatar props color as null is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user"
role="img"
title="name"
>
<span
Expand All @@ -50,6 +53,7 @@ exports[`EuiAvatar props color as plain is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user euiAvatar--plain"
role="img"
title="name"
>
<span
Expand All @@ -64,6 +68,7 @@ exports[`EuiAvatar props color as string is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user"
role="img"
style="background-color:#000;color:#FFFFFF"
title="name"
>
Expand All @@ -79,6 +84,7 @@ exports[`EuiAvatar props iconType and iconColor as null is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -94,6 +100,7 @@ exports[`EuiAvatar props iconType and iconColor is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -110,6 +117,7 @@ exports[`EuiAvatar props iconType and iconSize is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -126,6 +134,7 @@ exports[`EuiAvatar props iconType is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -142,6 +151,7 @@ exports[`EuiAvatar props imageUrl is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user"
role="img"
style="background-color:#e4a6c7;color:#000000;background-image:url(image url)"
title="name"
/>
Expand All @@ -151,6 +161,7 @@ exports[`EuiAvatar props initials is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -166,6 +177,7 @@ exports[`EuiAvatar props initialsLength is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -179,8 +191,8 @@ exports[`EuiAvatar props initialsLength is rendered 1`] = `

exports[`EuiAvatar props isDisabled is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user euiAvatar-isDisabled"
role="presentation"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -196,6 +208,7 @@ exports[`EuiAvatar props size l is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--l euiAvatar--user"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -211,6 +224,7 @@ exports[`EuiAvatar props size m is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--user"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -226,6 +240,7 @@ exports[`EuiAvatar props size s is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--s euiAvatar--user"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -241,6 +256,7 @@ exports[`EuiAvatar props size xl is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--xl euiAvatar--user"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand All @@ -256,6 +272,7 @@ exports[`EuiAvatar props type is rendered 1`] = `
<div
aria-label="name"
class="euiAvatar euiAvatar--m euiAvatar--space"
role="img"
style="background-color:#e4a6c7;color:#000000"
title="name"
>
Expand Down
3 changes: 2 additions & 1 deletion src/components/avatar/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ export const EuiAvatar: FunctionComponent<EuiAvatarProps> = ({
<div
className={classes}
style={avatarStyle}
aria-label={name}
aria-label={isDisabled ? undefined : name}
role={isDisabled ? 'presentation' : 'img'}
title={name}
{...rest}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ exports[`EuiComment props timelineIcon is rendered 1`] = `
<div
aria-label="Mario"
class="euiAvatar euiAvatar--l euiAvatar--user"
role="img"
style="background-color:#f1d86f;color:#000000"
title="Mario"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ exports[`EuiCommentTimeline props timelineIcon is rendered 1`] = `
<div
aria-label="Mario"
class="euiAvatar euiAvatar--l euiAvatar--user"
role="img"
style="background-color:#f1d86f;color:#000000"
title="Mario"
>
Expand Down