Skip to content

Commit

Permalink
chore: update accessibility of user avatar component (#1467)
Browse files Browse the repository at this point in the history
chore: update user avatar accessibility
  • Loading branch information
Chisomchima authored Jun 3, 2024
1 parent de6f005 commit 35482c7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/user-avatar/src/text-avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const TextAvatar = ({
medium,
small,
}) => (
<div className="text-avatar" data-test={dataTest}>
<div className="text-avatar" data-test={dataTest} aria-label={name}>
<div
className={cx('text-avatar-initials', {
extrasmall,
Expand Down
4 changes: 4 additions & 0 deletions components/user-avatar/src/user-avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const UserAvatar = ({
large,
medium,
small,
ariaLabel,
}) => (
<div
className={cx(className, {
Expand All @@ -37,6 +38,8 @@ const UserAvatar = ({
extralarge,
})}
data-test={dataTest}
aria-label={ariaLabel || name}
aria-hidden={!name}
>
{avatarId ? (
<ImageAvatar avatarId={avatarId} dataTest={`${dataTest}-image`} />
Expand Down Expand Up @@ -90,6 +93,7 @@ UserAvatar.propTypes = {
// SVG fallback with a `IconUser24`.
// This has been discussed and deferred
name: PropTypes.string.isRequired,
ariaLabel: PropTypes.string,
avatarId: PropTypes.string,
className: PropTypes.string,
dataTest: PropTypes.string,
Expand Down
1 change: 1 addition & 0 deletions components/user-avatar/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface UserAvatarProps {
large?: boolean
medium?: boolean
small?: boolean
ariaLabel?: string
}

export const UserAvatar: React.FC<UserAvatarProps>

0 comments on commit 35482c7

Please sign in to comment.