-
Notifications
You must be signed in to change notification settings - Fork 466
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
A more proper way to query form inline errors #634
Comments
We have a few options: (links are pointing to playgrounds)
Now, what I don't understand:
|
A little research shows me that adding support I have something working, but I need to attend a family thing first. I will check a bit more later. |
Really like your inputs, but I also think that the error message may not be unique as the form field id. If the message was only "Required" for both password and email for example you are stuck with the multiple elements found issue. |
True. But so might be your user who depends on a screen reader. |
References:
Describe the feature you'd like:
Until today, I've always used
getByTestId
to find a form inline error:But I'm always wondering if there is a more semantic / accessible way to both write the markup and find it in my tests.
In the html example I'm using the
output
tag with thefor
attribute (I'm still not very sure that its the proper use of this tag, lets discuss that 🤔), so maybe we could support a query likegetByRole('status', {name: 'something'})
or another moregetByLabelText
style.Suggested implementation:
I think that first we need to discuss the proper way to write an accessible inline form error and if possible to link it with its own input(s) (like a label).
Describe alternatives you've considered:
I've red in an article that a
<div role="alert">
can be used, but is missing way to link it to the input(s), and AFAIKrole="alert"
is not the same asrole="status"
(the role from output tag).Teachability, Documentation, Adoption, Migration Strategy:
Same as "Suggested Implementation"
The text was updated successfully, but these errors were encountered: