@@ -100,7 +100,7 @@ const Avatar = polymorphicComponent<'div', AvatarOwnProps, 'omitClassName'>(func
100100 ref ,
101101) {
102102 const label = getAvatarLabel ( { alt, name, 'aria-label' : ariaLabel } )
103- const isDecorative = ariaHidden || label === ''
103+ const isDecorative = Boolean ( ariaHidden ?? label === '' )
104104
105105 return (
106106 < Box
@@ -113,7 +113,6 @@ const Avatar = polymorphicComponent<'div', AvatarOwnProps, 'omitClassName'>(func
113113 exceptionallySetClassName ,
114114 ) }
115115 data-testid = { testId }
116- aria-hidden = { isDecorative || undefined }
117116 display = "inlineFlex"
118117 alignItems = "center"
119118 justifyContent = "center"
@@ -130,6 +129,7 @@ const Avatar = polymorphicComponent<'div', AvatarOwnProps, 'omitClassName'>(func
130129 name = { name }
131130 image = { image }
132131 label = { label }
132+ aria-hidden = { isDecorative }
133133 />
134134 </ Box >
135135 )
@@ -148,9 +148,10 @@ type AvatarImageProps = {
148148 name ?: string
149149 image ?: AvatarImageProp
150150 label ?: string
151+ 'aria-hidden' ?: boolean
151152}
152153
153- function AvatarImage ( { size, name, image, label } : AvatarImageProps ) {
154+ function AvatarImage ( { size, name, image, label, 'aria-hidden' : ariaHidden } : AvatarImageProps ) {
154155 const imageSources = getSources ( image , size )
155156 const [ failedImageSources , setFailedImageSources ] = React . useState < string [ ] > ( [ ] )
156157 const availableImageSources = getAvailableImageSources ( imageSources , failedImageSources )
@@ -165,6 +166,7 @@ function AvatarImage({ size, name, image, label }: AvatarImageProps) {
165166 srcSet = { availableImageSources . srcSet }
166167 sizes = { availableImageSources . sizes }
167168 alt = { label }
169+ aria-hidden = { ariaHidden }
168170 onError = { ( event ) => {
169171 const failedSource = getFailedImageSource (
170172 availableImageSources ,
@@ -189,6 +191,7 @@ function AvatarImage({ size, name, image, label }: AvatarImageProps) {
189191 ) }
190192 role = { label ? 'img' : undefined }
191193 aria-label = { label }
194+ aria-hidden = { ariaHidden }
192195 >
193196 { initials }
194197 </ div >
0 commit comments