Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a11y: Error messages are not programmatically associated with form fields #3146

Closed
Kinbaum opened this issue Dec 8, 2022 · 4 comments
Closed
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)

Comments

@Kinbaum
Copy link
Contributor

Kinbaum commented Dec 8, 2022

What package has an issue

@mantine/core

Describe the bug

Visible error messages are not programmatically associated with their related form fields. As a result, screen reader users will not hear an announcement of the associated error message when they focus on an input field.

Screen Shot 2022-12-08 at 7 57 46 AM

What version of @mantine/hooks page do you have in package.json?

5.9.2

If possible, please include a link to a codesandbox with the reproduced problem

https://mantine.dev/core/text-input/

Do you know how to fix the issue

Yes

Are you willing to participate in fixing this issue and create a pull request with the fix

None

Possible fix

Programmatically associate the error message for any form field in error using aria-describedby.  Remove the aria-describedby attribute when errors are resolved and the visible error message disappears.

The role="alert" should not be on these errors either. That can make for a bunch of announcements if a user is just tabbing through each field with a screen reader on.

Screen Shot 2022-12-08 at 8 03 02 AM

@rtivital
Copy link
Member

rtivital commented Dec 8, 2022

@Kinbaum how should we handle the case when input has both error and description?

image

@Kinbaum
Copy link
Contributor Author

Kinbaum commented Dec 8, 2022

They would both be referenced in the aria-describedby attribute, with the error first and description second. So if the error had an id="error-1" and the description was id="desc-1", the attribute on the <input> would be aria-describedby="error-1 desc-1"

Then when the error is cleared it would go back to just aria-describedby="desc-1"

@rtivital
Copy link
Member

rtivital commented Dec 8, 2022

Alright, thanks for reporting and explanation, the issue will be fixed in one of the next patches

@rtivital rtivital added the Fixed patch Completed issues that will be published with next patch (1.0.X) label Dec 12, 2022
rtivital added a commit that referenced this issue Dec 12, 2022
…Description and Input.Error to the input element with aria-describedby (#3146)
@rtivital
Copy link
Member

Fixed in 5.9.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

No branches or pull requests

2 participants