Skip to content

fix(Avatar): no public data-initials attribute; the initials come from a private StyleX dynamic style - #10944

Merged
cixzhang merged 3 commits into
mainfrom
l0/avatar-initials-private-content
Nov 10, 2026
Merged

cixzhang merged 3 commits into
mainfrom
l0/avatar-initials-private-content

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Since the Avatar Label in Name fix, which is in no release yet, the initials were stored in a public data-initials attribute on the page. A public attribute becomes part of Avatar's API: callers and tests start depending on it. This change removes the attribute before the next release.

What people see and hear does not change:

  • The initials look the same.
  • Screen readers and speech input get only the person's name.

Problem and solution fit

The initials need to be drawn without being text of the control, so they stay out of the accessible name (WCAG 2.5.3 Label in Name). The earlier change used content: attr(data-initials), which needs an attribute. Now a StyleX dynamic style sets the quoted initials as a hashed, per-instance inline custom property, and the ::before draws it:

  • content: var(--x-…) draws the plain string.
  • Inside @supports (content: "a" / ""), content: var(--x-…) holds "<initials>" / "", so engines that read alternative text for generated content get an empty one.

No custom property is named by hand, and no caller style is used. The string is CSS-quoted with quotes and backslashes escaped.

Older engines (Safari before 17.4, Firefox before 128) skip the @supports rule and draw the plain string. A link or button avatar is named by its aria-label, which overrides content, and a static avatar is role="img" with its name, which hides its children. In both cases a screen reader on an older engine hears only the person's name.

Expected behavior and authority

  • component:Avatar AR1 now says: "The initials are drawn by generated content from a private per-instance CSS variable, so they stay out of the accessible name; Avatar renders no public attribute for them."
  • The project owner decided to remove the public attribute before release.

Smallest restoration

  • Avatar.tsx: the static attr(data-initials) rule and the attribute are gone. The initials dynamic style and a small cssString helper replace them.
  • Release notes: the earlier unreleased Avatar Changeset drops its data-initials sentence, so the next changelog describes only the shipped behaviour. No second Changeset is added.
  • Tests that read the initials now read the private inline property: Avatar, the lab CommentPin, and the CLI render test.
  • A "Tricky names (initials)" story covers quotes, a backslash, emoji and a flag on link, button and static avatars.

Evidence

  • Red first: on main, the Avatar and CommentPin suites fail (29 tests), including "renders no public attribute for the initials" and the rule-level check below.
  • A unit test checks the compiled CSS: a plain ::before { content: var(--x-…) } rule plus an @supports (content: "a" / "") rule. The inline property holds "AL" for one and "AL" / "" for the other.
  • AvatarLabelInName.a11y.chromium.spec.ts becomes AvatarLabelInName.a11y.browser.spec.ts, the cross-browser naming that the local Playwright config runs in Chromium and WebKit. The CI workflows currently run it in Chromium only. It checks four things:
    • axe label-content-name-mismatch is clean;
    • each control has no text and is named by the person;
    • the initials draw as generated content, also under forced colors;
    • no data-initials attribute is on the page.
  • Real Chrome 157 on the preview Storybook, at the previous head; the code is identical at this head:
    • Attribute: no data-initials anywhere on the page in the "Tricky names", "Interactive" and "Initials fallback" stories.
    • Drawing: the initials draw via ::before in light, dark and forced colors, with computed content such as "AL" / "" and "OB" / "".
    • Names: accessible names are the person's name only, for example link "Ada "The Countess" Lovelace", button "O\Brien Back\slash", img "Zoë "Z" Kravitz" and button "Dorothy Vaughan, Online". No initials text is in the accessibility tree.
    • CSS: the compiled stylesheet has the plain content: var(--x-…) rule plus a separate @supports (content: "a" / "") rule.
    • Console: no errors.
  • iOS VoiceOver on an iPhone 14 (iOS 26.2): the avatar reads "John Doe, Image", with no initials text. "JD" is read only when iOS Text Recognition is on, which reads drawn text from the screen.
  • Evidence summary. Checked:
    • Chrome: a full pass of drawing, accessible names, axe and forced colors.
    • Safari on a real iPhone 14: initials drawn, the accessible name is the person's name, VoiceOver correct.
    • Mobile Safari in the iOS 26.2 Simulator: axe label-content-name-mismatch has 0 violations and 0 incomplete across light and dark in two stories. CSS.supports('content: "a" / ""') is true, and every ::before uses the "XX" / "" form, the tricky names included. There is no data-initials.
    • Firefox for Android 159: initials visible in light and dark; axe label-content-name-mismatch has 0 violations; CSS.supports('content: "a" / ""') is true, and ::before uses the "XX" / "" form; no data-initials. The accessible name was verified from the DOM; Firefox's accessibility tree was not inspected. CI covers Chromium and WebKit. Older engines fall back to the plain content and the aria-label name.
  • Representative unchanged path: the photo avatar, the forced-colors initials colour, grouped avatars and sizes. 717 tests pass across the Avatar, AvatarGroup, CommentPin, ChatMessage, StatusDot and theming-target suites.

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/lab/src/CommentPin packages/core/src/Chat/ChatMessage.test.tsx packages/core/src/StatusDot packages/core/src/theme/themingTargets.test.ts: 717 passed.
  • Core tsc, eslint, check:knowledge, check:changesets, and the comment-provenance baseline.
  • The CLI render test and the browser spec run in CI.

Writing rubric results

Run over the Avatar.spec.md edits (one AR1 sentence, a renamed verification file).

  • R1 narration: none.
  • R2 research in the record: none.
  • R3 evidence naming a change: none.
  • R4 rejected alternatives over one line or outside a decision: none.
  • R5 pull request or issue references remaining: none.
  • R6 ruled open questions still listing options: none.

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

…ith no public data-initials attribute

A StyleX dynamic style sets the quoted initials as a hashed inline
custom property. The ::before draws it plainly, and as
'<initials> / ""' (empty alternative text) where @supports allows,
so the initials stay out of the accessible name. The Label in Name
spec runs in WebKit too.
@vercel

vercel Bot commented Nov 10, 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 10, 2026 3:38am UTC

Request Review

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 10, 2026
@astracat-bot

astracat-bot Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 10, 2026, 4:07 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 10, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 10, 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 10, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 5dc5130

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 10, 2026
@cixzhang
cixzhang marked this pull request as draft November 10, 2026 03:07
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 10, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec f9ab850

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 21774da

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
lab/Comments 352.2 kB (+133 B) · 2.5 kB CSS (0) — — · — · —
Avatar 43.5 kB (+106 B) · 5.6 kB CSS (+26 B) — ✓ · ✓ · ✓
AvatarGroup 46.2 kB (+95 B) · 5.7 kB CSS (+26 B) — — · — · —
6 more components
Component Size LoC Visual · A11y · RTL
PowerSearch 288.5 kB (+86 B) · 24.2 kB CSS (+29 B) — — · — · —
lab/CommentComposer 152.3 kB (+115 B) · 1.9 kB CSS (0) — — · — · —
lab/CommentThread 345.3 kB (+100 B) · 2.4 kB CSS (0) — — · — · —
AvatarGroupOverflow 49.1 kB (+72 B) · 5.7 kB CSS (+26 B) — — · — · —
lab/CommentPin · Storybook 57.4 kB (+95 B) · 1.2 kB CSS (0) 413 (0) — · ✓ · —
AvatarStatusDot 7.5 kB (0) · 3.5 kB CSS (0) — ✓ · ✓ · ✓

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

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 36 rows; 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

@cixzhang
cixzhang marked this pull request as ready for review November 10, 2026 03:10

@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.

Changes requested: the Avatar change itself holds up, but it leaves the release notes contradicting each other.

  • .changeset/avatar-initials-label-in-name.md still tells consumers that tests read the data-initials attribute, while the new .changeset/avatar-initials-private-content.md says that attribute is gone; neither has shipped, so both land in the same changelog — please drop or replace that last sentence of the earlier changeset and delete or reword the new one so the notes describe only the change since the last release.

The initials render pixel-identically to main, and the new tests, the server-render test and a Chromium and WebKit check of the accessible names all pass. Two optional points: the new comment above dynamicStyles.initials would read better as short sentences, and the description says CI runs the Label in Name spec in WebKit, but the workflows run it in Chromium only.

[Automated review]

Comment thread packages/core/src/Avatar/Avatar.tsx Resolved
@cixzhang
cixzhang marked this pull request as draft November 10, 2026 03:31
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 21774da

@cixzhang
cixzhang marked this pull request as ready for review November 10, 2026 03:42

@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. Avatar no longer writes the unreleased data-initials attribute, the initials draw exactly as before, and the release notes now agree with each other.

One optional fix: the description says CI runs the Label in Name spec in Chromium and WebKit, but CI's accessibility job runs it in Chromium only, so WebKit covers it only when run locally.

[Automated review]

@cixzhang
cixzhang merged commit 00e031a into main Nov 10, 2026
189 checks passed
@github-actions
github-actions Bot deleted the l0/avatar-initials-private-content branch November 10, 2026 06:04
cixzhang added a commit that referenced this pull request Nov 12, 2026
failingSpecs no longer waits after its fourth and last try, so a log that keeps
answering 5xx gives up after 30 s of waits, and a test pins four server errors
in a row. This also corrects the earlier commit's wording: the three pull
requests that now replay a narrow selection (#9672, #10271, #10944) are ones
whose story was their only full-suite trigger, not ones that change only
stories. Their stories are Drawer, TableSelection and Avatar; Button's specs run
because those stories import Button.
cixzhang added a commit that referenced this pull request Nov 12, 2026
… retries a server error (#11317)

* ci: the selection replay record covers the story rule; a log download retries a server error

The record is regenerated with the Chromium lane's story rule (#11250). Every
verdict matches the earlier record: 144 no failure, 4 caught, 4 reviewed, 1 out
of scope. Three pull requests that change only stories now replay a narrow
selection with no failure (#9672, #10271, #10944). GitHub's job-log endpoint
answers 502 now and then, so failingSpecs tries a server error again, up to
four times, before it calls a log unreadable.

* Merge remote-tracking branch 'origin/main' into ci/replay-story-rule

* ci: a log download waits only between tries, not after the last

failingSpecs no longer waits after its fourth and last try, so a log that keeps
answering 5xx gives up after 30 s of waits, and a test pins four server errors
in a row. This also corrects the earlier commit's wording: the three pull
requests that now replay a narrow selection (#9672, #10271, #10944) are ones
whose story was their only full-suite trigger, not ones that change only
stories. Their stories are Drawer, TableSelection and Avatar; Button's specs run
because those stories import Button.

This branch was successfully deployed

1 active deployment
Preview — 21774daf Deployed Nov 10, 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant