Skip to content

fix(avatar): decorative when unnamed + no double-announce (obs-9)#3427

Merged
cixzhang merged 1 commit into
mainfrom
navi/fix/avatar-accessible-name
Jul 2, 2026
Merged

fix(avatar): decorative when unnamed + no double-announce (obs-9)#3427
cixzhang merged 1 commit into
mainfrom
navi/fix/avatar-accessible-name

Conversation

@cixzhang

@cixzhang cixzhang commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Part of the accessibility & keyboard-management program (#3343). Fixes observation obs-9.

Problem

Avatar computed accessibleName = alt || name || 'Avatar' on a role="img" wrapper, so an avatar with neither alt nor name was announced as the meaningless generic "Avatar, image" — noise for screen-reader users, with no decorative opt-out. Additionally the outer role="img" (named) contained an inner <img alt={accessibleName}>, double-announcing the name.

Fix

  • With no alt and no name, the avatar is decorative: role="presentation" + aria-hidden (no generic "Avatar" label).
  • When named, the inner <img> uses alt="" so the accessible name is announced once (by the role="img" wrapper), not twice.

Tests

Adds a colocated Avatar.test.tsx: named avatar exposes role="img" with the name; alt wins over name; an unnamed avatar is decorative (aria-hidden, no role="img"); the inner image is alt="" when the wrapper is named. Full Avatar + AvatarGroup suites green (20 tests), typecheck + lint clean.

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 2, 2026 2:06pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Jul 2, 2026
@cixzhang cixzhang marked this pull request as ready for review July 2, 2026 17:36
@nynexman4464 nynexman4464 self-assigned this Jul 2, 2026

@nynexman4464 nynexman4464 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable. Can confirm voicover ignores the avatar element when the alt/name text is not provided. I wonder if there's a way to make that clear in the doc. Ideally this is only done when there isn't another alternative accessible text describing the person/image.

@cixzhang cixzhang merged commit ce5d969 into main Jul 2, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants