Skip to content

fix(Avatar): an interactive initials avatar passes Label in Name - #10816

Merged
cixzhang merged 3 commits into
mainfrom
l0/avatar-initials-label-in-name
Nov 10, 2026
Merged

cixzhang merged 3 commits into
mainfrom
l0/avatar-initials-label-in-name

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

User impact

An interactive Avatar (href or onClick) with no photo shows the person's initials, for example "JD", but its accessible name is the full name, "Jane Doe". "JD" is not part of "Jane Doe", so:

  • axe-core 4.14 reports label-content-name-mismatch (WCAG 2.5.3 Label in Name, now a regular wcag21a rule) on every clickable initials avatar. Product teams that run axe with the WCAG 2.1 tags get a failure they cannot fix from outside.
  • A speech-input user who says what they see gets no match for a text label.

After this change, the initials are part of the picture, like the photo: they are drawn as generated content, not text. The accessible name, the name tooltip (on hover and keyboard focus) and the initials' appearance are unchanged. Tests that find initials by text read data-initials instead; the lab CommentPin test is updated.

Fixes #8936.

Problem and solution fit

  • Why does it fail? The initials are text inside the link or button, so they count as its visible text label, and the name does not contain them.
  • Why does that harm the task? Label in Name says the visible label must be part of the name. Tools and speech input match what is visible against the name.
  • Why does it matter? Every clickable initials avatar fails an automated WCAG A check, and product teams cannot override it.

The initials are a stand-in for the photo, which the record already treats as decorative. Drawing them as generated content with empty alternative text makes them part of the picture: they stay on screen, but they are not text of the control. Putting the initials into the name instead ("JD, Jane Doe") would make every screen-reader user hear letters, so this PR does not do that.

Expected behavior and authority

  • component:Avatar FR5, ORD2, AR1 and AR3 name the avatar by the person and treat inner pictures as decorative. This PR adds one AR1 line: initials are the photo's fallback and decorative like an inner image, on every root, and the FR7 tooltip shows the name on hover and focus.
  • The record line was ruled consistency with the existing model, so it needs no owner card.
  • WCAG 2.2 SC 2.5.3 Label in Name.

Smallest restoration

  • Avatar.tsx: the initials element carries data-initials, and a ::before draws attr(data-initials) / "". Browsers without alternative-text syntax fall back to attr(data-initials). The initials element, its theme target (avatar-fallback), sizes, colors and forced-colors rule are unchanged.
  • No API, default or visual change.

Evidence

  • Reproduction before the change: the new unit suite fails on main. All three roots (static, link, button) have "AL" as text content, and the compiled ::before rule is missing.
  • Result after the change: those roots have no text content and are named "Ada Lovelace", and the initials come from data-initials.
  • Representative unchanged path: a photo avatar has no initials and is still named by the person.
  • Browser proof (new AvatarLabelInName.a11y.chromium.spec.ts, which runs in CI's Chromium leg):
    • axe label-content-name-mismatch finds nothing on the Interactive story.
    • The initials draw as generated content, with and without forced colors.
    • Keyboard focus on an initials link shows the name tooltip.
  • The existing forced-colors spec keeps checking the initials' color.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run packages/core/src/Avatar packages/core/src/AvatarGroup packages/core/src/theme/themingTargets.test.ts: 612 passed. The new suite fails on main.
  • Core tsc, eslint, check:knowledge, check:changesets, and the comment-provenance baseline.
  • The Chromium spec runs in CI. Before-and-after screenshots follow in a comment.

Writing rubric results

Run over the Avatar.spec.md edits (one AR1 paragraph, one verified_by entry, one verification row).

  • R1 narration: none. The text is present tense.
  • R2 research in the record: none.
  • R3 evidence naming a change: none. The row names tests.
  • R4 rejected alternatives over one line or outside a decision: none in the record. The rejected alternative is only in this description.
  • R5 pull request or issue references remaining: none.
  • R6 ruled open questions still listing options: none.

(Posted by Cindy's agent on her behalf.)

…vatar passes Label in Name

The initials render as generated content with empty alternative text.
A link or button avatar is named only by the person's name, and no
visible text label sits outside that name. The record's AR1 says so,
with a unit suite and a Chromium axe spec.
@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 9, 2026 11:02pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 9, 2026
@astracat-bot

astracat-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 9, 2026, 11:29 PM UTC

@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec ecc7572

@github-actions github-actions Bot added needs:spec-owner-review Current knowledge records await owner approval and removed needs:spec-owner-review Current knowledge records await owner approval labels Nov 9, 2026
@cixzhang cixzhang added ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) labels Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 1206dee

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Avatar 43.4 kB (+37 B) · 5.6 kB CSS (+38 B) — ✓ · ✓ · ✓
AvatarGroupOverflow 49.1 kB (+37 B) · 5.6 kB CSS (+38 B) — — · — · —
AvatarGroup 46.1 kB (+24 B) · 5.7 kB CSS (+39 B) — — · — · —
6 more components
Component Size LoC Visual · A11y · RTL
PowerSearch 287.7 kB (+31 B) · 24.2 kB CSS (+25 B) — — · — · —
lab/CommentThread 344.6 kB (+40 B) · 2.4 kB CSS (0) — — · — · —
lab/CommentPin · Storybook 57.3 kB (+35 B) · 1.2 kB CSS (0) 413 (0) — · ✓ · —
lab/CommentComposer 152.2 kB (+27 B) · 1.9 kB CSS (0) — — · — · —
lab/Comments 351.5 kB (+20 B) · 2.5 kB CSS (0) — — · — · —
AvatarStatusDot 7.5 kB (0) · 3.5 kB CSS (0) — ✓ · ✓ · ✓

Package size: @astryxdesign/core 7.22 MB packed (+228 B); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 36 rows, theme-butter 1 row, theme-y2k 1 row; run pnpm api:report.

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot 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.

Requesting changes. The Avatar change itself holds up: the initials look and announce the same, and axe's label-content-name-mismatch no longer fires on link or button avatars. Two things need fixing before merge:

  • packages/lab/src/CommentPin/CommentPin.test.tsx:146 still expects the pin's text to be AL, so test-ui (2/4) fails now that the initials are generated content; assert that the pin has no text and contains [data-initials="AL"] instead.
  • The changeset says the link or button is now "named only by the person's name" and that the tooltip "shows that name on hover and focus", but both were already true before this change, so reword it to say that only the initials stopped being text (name, tooltip and look unchanged) and that tests reading initials by text should use data-initials.

Optional: the new comment in Avatar.tsx can be shorter (inline suggestion). The Item.swipeLayer failure in test-ui (3/4) does not involve Avatar, so a re-run should clear it.

[Automated review]

Comment thread packages/core/src/Avatar/Avatar.tsx Resolved
@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 4cec8ea

@astracat-bot astracat-bot Bot 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.

Approved pending CI: the full CI run for this head is still in progress, so this is not cleared to land until it passes.

Avatar's initials are now drawn as decorative generated content, so axe's label-content-name-mismatch no longer fires on link or button avatars, while their accessible names, the name tooltip and every rendered frame stay the same. The new Avatar tests and the Chromium spec fail on main and pass here. Consumer tests that found initials by text now need data-initials, which the changeset already says.

[Automated review]

@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 1206dee

@astracat-bot astracat-bot Bot 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.

Approved pending CI: the heavy suites (test, build, docsite-test) are deferred on this head and run before merge, so this is not cleared to land until they pass.

The initials are now generated content with empty alternative text, so link and button avatars no longer carry a visible text label outside their name. axe's label-content-name-mismatch drops from 10 failing nodes to 0 on the Avatar Interactive story, the new Avatar tests fail on main and pass here, and names, the focus tooltip and pixels are unchanged.

Two non-blocking suggestions:

  • Miss: Avatar.spec.md AR1: "so the accessible name is only the person's name" reads as if the status label FR5 composes were excluded, but the tests still expect "Ada Lovelace, Busy". "so the initials add nothing to the name FR5 resolves" is exact.
  • Miss: Firefox 125-127 take the plain attr(data-initials) fallback without alternative text, so they still expose the letters as text. A sentence in AR1, or a gap line, would document that reduced fallback (spec:AST-013 FR7).

[Automated review]

This branch was successfully deployed

1 active deployment
Preview — 1206dee4 Deployed Nov 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) 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.

[Bug] Avatar: an interactive avatar that shows initials fails Label in Name (label-content-name-mismatch)

1 participant