spectrum-web-components icon indicating copy to clipboard operation
spectrum-web-components copied to clipboard

[Bug]: avatar should render an alt tag even if no label is specified to avoid a11y violations.

Open Rajdeepc opened this issue 6 months ago • 3 comments

Code of conduct

  • [x] I agree to follow this project's code of conduct.

Impacted component(s)

avatar

Expected behavior

<!-- After -->
<sp-avatar src="image.jpg"></sp-avatar>
<!-- Renders as: -->
<img class="image" alt="" src="image.jpg">

Actual behavior

<!-- Before -->
<sp-avatar src="image.jpg"></sp-avatar>
<!-- Rendered as: -->
<img class="image" src="image.jpg">

Screenshots

No response

What browsers are you seeing the problem in?

Microsoft Edge, Safari, Chrome, Firefox

How can we reproduce this issue?

  1. Go to https://opensource.adobe.com/spectrum-web-components/components/avatar/#sizes
  2. Remove label property
  3. Open Dev Console
  4. Check img doesnt have alt attribute

Sample code or abstract reproduction which illustrates the problem

No response

Severity

None

Logs taken while reproducing problem

No response

Would you like to track this issue in Jira?

  • [x] Yes, please tell me the ticket number!

Rajdeepc avatar Jun 04 '25 13:06 Rajdeepc

SWC-915

Rajdeepc avatar Jun 10 '25 06:06 Rajdeepc

I don't think we should make avatars decorative if someone were to omit the label. I think that will hide too many real issues where someone just forgot to add a label to something which is not decorative. If we are to do this I beleive we should use an intentional attribute a developer would specify (such as isdecorative). Until this time I think adding aria-hidden="true" to sp-avatar will solve the immediate issue.

jnurthen avatar Jun 10 '25 18:06 jnurthen

When avatar is used as a link it absolutely must have a label. For accessibility anything focusable should be labeled and not aria-hidden

nikkimk avatar Aug 01 '25 19:08 nikkimk