Skip to content

fix(a11y): name RichTextEditor and RichTextView text surfaces - #4685

Open
AKnassa wants to merge 1 commit into
facebook:mainfrom
AKnassa:fix/a11y-richtexteditor-name
Open

fix(a11y): name RichTextEditor and RichTextView text surfaces#4685
AKnassa wants to merge 1 commit into
facebook:mainfrom
AKnassa:fix/a11y-richtexteditor-name

Conversation

@AKnassa

@AKnassa AKnassa commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Part of #4681 (weekly a11y scan). Clears all 13 RichTextEditor entries from the axe baseline: 12x aria-input-field-name (serious) and 1x label (critical).

What this does

Screen readers currently announce the RichTextEditor's editing area with no name, in every story. This PR wires up the accessible names so the editor, the read-only view, and the one demo textarea all announce what they are.

Why the violations happened

  • The editor pointed aria-labelledby at the control id, but no element carries that id. A <label htmlFor> association cannot name a contenteditable div, so the name resolved to empty.
  • RichTextView renders Lexical's ContentEditable, which keeps role="textbox" (plus aria-readonly) even when non-editable, with no way to name it from outside. Swapping the role instead would trade this for a critical aria-allowed-attr violation, since Lexical hardcodes aria-readonly and only textbox-family roles allow it.
  • The Markdown Serializers story rendered a bare <textarea> demo input.

What changed

  • RichTextEditor passes labelID to Field and points aria-labelledby at the label element; the contenteditable now carries the control id that htmlFor expects.
  • RichTextView gains an optional label prop applied as aria-label on the text region, defaulting to 'Rich text content' (same pattern as RichTextEditorToolbar's label default).
  • The Markdown Serializers story labels its demo textarea; both RichTextView story usages pass contextual labels.
  • .github/a11y-baseline.json: 226 -> 213 entries (deletions only).

Verification

  • 3 new tests (visible-label name on the editor, default and custom name on the view); 53/53 lab tests pass.
  • lab typecheck:docs and storybook typecheck pass.
  • Full axe audit (accessibility-audit.js --components RichTextEditor --fail-on-new against the trimmed baseline): 0 violations across all 12 stories.

No changeset: lab package (canary only), stories, and CI config.

axe flagged every RichTextEditor story (aria-input-field-name,
12 serious + 1 critical label): the editor pointed aria-labelledby
at an id no element carried, RichTextView's read-only textbox had
no name at all, and one story shipped a bare textarea.

- point aria-labelledby at the label element via Field's labelID,
  and give the contenteditable the control id htmlFor expects
- add a label prop to RichTextView (default 'Rich text content'),
  mirroring RichTextEditorToolbar's label default
- label the Markdown Serializers story textarea
- burn 13 fixed entries out of .github/a11y-baseline.json (226->213)

Verified: 53/53 lab tests, lab typecheck:docs, storybook typecheck,
and the full axe audit on all 12 stories - 0 violations, gate green.

Part of facebook#4681.
@vercel

vercel Bot commented Aug 3, 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 Aug 3, 2026 6:00pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 3, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Aug 3, 2026
@AKnassa
AKnassa marked this pull request as ready for review August 3, 2026 22:32
@github-actions

github-actions Bot commented Aug 4, 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.

Modified Components

RichTextEditor (@astryxdesign/lab) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1305 -
Complexity N/A Very High (75) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/lab N/A 3.4KB 1.4KB

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 Aug 4, 2026
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. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant