fix(a11y): give profile link a proper accessible name (#52109)

This commit is contained in:
Bruce Blaser
2023-10-25 23:46:01 -07:00
committed by GitHub
parent 167cbead7a
commit c295539ca8
3 changed files with 9 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ function DefaultAvatar(
width='500px'
xmlns='http://www.w3.org/2000/svg'
xmlnsXlink='http://www.w3.org/1999/xlink'
aria-hidden='true'
{...props}
>
<title>{t('icons.avatar')}</title>

View File

@@ -9,12 +9,10 @@ interface AvatarRendererProps {
isDonating?: boolean;
isTopContributor?: boolean;
picture: string;
userName: string;
}
function AvatarRenderer({
picture,
userName,
isDonating,
isTopContributor
}: AvatarRendererProps): JSX.Element {
@@ -44,14 +42,11 @@ function AvatarRenderer({
return (
<div className={`avatar-container ${borderColor}`}>
<span className='sr-only'>{t('buttons.profile')}</span>
{isPlaceHolderImage ? (
<DefaultAvatar className='avatar default-avatar' />
) : (
<Image
alt={t('profile.avatar', { username: userName })}
className='avatar'
src={picture}
/>
<Image alt='' className='avatar' src={picture} />
)}
</div>
);

View File

@@ -23,7 +23,13 @@ exports[`<Profile/> renders correctly 1`] = `
<div
class="avatar-container default-border"
>
<span
class="sr-only"
>
buttons.profile
</span>
<svg
aria-hidden="true"
class="avatar default-avatar"
height="500px"
version="1.1"