Skip to content

Conversation

@sandranymark
Copy link

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 as a direct child of the

    rendered by FieldGroup.

  • Intended for use in FieldGroup components.

Issue(s)

Screenshots

Fieldset-missing-legend

Skärmbild 2025-06-12 121155

image

FieldGroup-test

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.

@changeset-bot
Copy link

changeset-bot bot commented Jun 12, 2025

⚠️ No Changeset found

Latest commit: e5dae36

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

@CLAassistant
Copy link

CLAassistant commented Jun 12, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants