Skip to content

Commit

Permalink
[EuiAvatar] Adding conditionalrole attribute to EuiAvatar container…
Browse files Browse the repository at this point in the history
… DIV (#5423)

* Adding conditional role to Avatar container div
* Adding CHANGELOG entry
* Update CHANGELOG.md
🎉 
Co-authored-by: Constance <[email protected]>
Co-authored-by: Constance <[email protected]>
  • Loading branch information
1Copenut authored Nov 30, 2021
1 parent 00d4591 commit 68b1a71
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ No public interface changes since `41.4.0`.
**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

0 comments on commit 68b1a71

Please sign in to comment.