feat: WCAG (1.3.1) add FieldLegend component to address missing legend
Proposed changes (including videos or screenshots)
Adds a new FieldLegend component that renders a visually hidden <legend> to be used inside FieldGroup components. This addresses the “missing legend” warning reported by WAVE and improves semantic structure in accordance with WCAG 1.3.1 – Info and Relationships.
-
Uses @react-aria/visually-hidden to visually hide the legend while keeping it accessible to assistive technologies.
-
Ensures semantic correctness by preserving the required
-
Intended for use in FieldGroup components.
Issue(s)
Screenshots
Further comments
I've tried to hide the <legend> element both visually and from screen readers to avoid redundancy and improve accessibility.
I'm using @react-aria/visually-hidden to hide the legend in a way that removes it from the visual flow and from screen reader output.
This is important because the same text (t('DummyText')) is already passed to <AccordionItem title={t('DummyText')}>, which provides both the visible label and the screen reader announcement. Including it again in a <legend> would result in redundant information for assistive technologies.
The goal here is to preserve the semantic structure (keeping the <legend> as part of the DOM) while avoiding duplicate announcements.
From a WCAG perspective, this approach should be acceptable, since FieldLegend is still a direct child of FieldGroup (which renders a <fieldset>), and a <fieldset> requires a <legend> for semantic correctness.
⚠️ No Changeset found
Latest commit: e5dae3694ebbff4c74402a7a9d520acf390da465
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR