Skip to content

feat(field): use aria-errormessage for error text association#3883

Open
justintoman wants to merge 1 commit into
chakra-ui:mainfrom
justintoman:feat/field-aria-errormessage
Open

feat(field): use aria-errormessage for error text association#3883
justintoman wants to merge 1 commit into
chakra-ui:mainfrom
justintoman:feat/field-aria-errormessage

Conversation

@justintoman
Copy link
Copy Markdown

@justintoman justintoman commented May 13, 2026

Field.ErrorText is currently associated with the control via aria-describedby. I believe aria-errormessage is the semantically correct attribute for this relationship. It exists specifically to identify error messages and pairs with aria-invalid.

Testing Library and Playwright both ship toHaveAccessibleErrorMessage() as a first-class assertion that reads aria-errormessage. I take that to mean this API should be stable and safe to support. I discovered this because I was attempting to write unit tests in my project with both of those and realized I couldn't use toHaveAccessibleErrorMessage() out of the box with Ark UI.

This change should be minimal because the infrastructure already correctly sets aria-invalid and determines hasErrorText with a MutationObserver. The error text ID just needs to move from aria-describedby to aria-errormessage, leaving aria-describedby for helper text exclusively, which I believe is the correct semantic split.

Thank you!

@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

@justintoman is attempting to deploy a commit to the Chakra UI Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant