Repository navigation
fix(Avatar): an interactive initials avatar passes Label in Name - #10816
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec ecc7572 |
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
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:146still expects the pin's text to beAL, sotest-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]
…and comment say only what changed
|
/approve-spec 4cec8ea |
There was a problem hiding this comment.
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]
|
/approve-spec 1206dee |
There was a problem hiding this comment.
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.mdAR1: "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-013FR7).
[Automated review]
User impact
An interactive Avatar (
hreforonClick) 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:label-content-name-mismatch(WCAG 2.5.3 Label in Name, now a regularwcag21arule) on every clickable initials avatar. Product teams that run axe with the WCAG 2.1 tags get a failure they cannot fix from outside.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-initialsinstead; the lab CommentPin test is updated.Fixes #8936.
Problem and solution fit
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:AvatarFR5, 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.Smallest restoration
Avatar.tsx: the initials element carriesdata-initials, and a::beforedrawsattr(data-initials) / "". Browsers without alternative-text syntax fall back toattr(data-initials). The initials element, its theme target (avatar-fallback), sizes, colors and forced-colors rule are unchanged.Evidence
main. All three roots (static, link, button) have "AL" as text content, and the compiled::beforerule is missing.data-initials.AvatarLabelInName.a11y.chromium.spec.ts, which runs in CI's Chromium leg):label-content-name-mismatchfinds nothing on the Interactive story.Scope
Testing
vitest run packages/core/src/Avatar packages/core/src/AvatarGroup packages/core/src/theme/themingTargets.test.ts: 612 passed. The new suite fails onmain.tsc, eslint,check:knowledge,check:changesets, and the comment-provenance baseline.Writing rubric results
Run over the
Avatar.spec.mdedits (one AR1 paragraph, oneverified_byentry, one verification row).(Posted by Cindy's agent on her behalf.)