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

fix: Textarea accessibility #22

Merged
merged 4 commits into from
Jun 18, 2019
Merged

fix: Textarea accessibility #22

merged 4 commits into from
Jun 18, 2019

Conversation

jsomsanith-tlnd
Copy link
Contributor

@jsomsanith-tlnd jsomsanith-tlnd commented Jun 18, 2019

What is the problem this PR is trying to solve?
Textarea component is not accessible.

  1. label semantic is not correct.
  2. labels are not associated to the textarea. Focusing on the textarea, SR won't read the label.
  3. labels are not required.
  4. invalid textarea should have aria-invalid attribute.
  5. errors are not associated to textarea. Focusing on the textarea, SR won't read the error.
  6. error is before the textarea. SR will read it, but blind people don't know that there is an associated textarea until they focus on the next element. It lacks some context.
  7. subtext is not associated to the textarea

What is the chosen solution to this problem?

  1. use <label>
  2. accept a required props id that is passed to the textarea. Use htmlFor react attribute to associate the label with the textarea through the id.
  3. labels are required, introducing a hideLabel props if we want it not to be displayed.
  4. add aria-invalid attribute on textarea with error
  5. generate an error id based on the props.id, that is passed to the error element. Use aria-describedby on the textarea to associate the error with it.
  6. hide the error from SR. It is still associated to the textarea, focusing on it will make SR read the error too.
  7. same as error, generate an id and associate it via aria-describedby

@domyen
Copy link
Member

domyen commented Jun 18, 2019

Nice! I'm going to merge this. I think the inputs and textareas are complex enough to warrant documenting them via Storybook Docs. That would help articulate the finer points of usage and accessibility attrs aria-....

@domyen domyen merged commit 52b33cd into master Jun 18, 2019
@domyen domyen deleted the jsomsanith/fix/textarea_a11y branch June 18, 2019 22:13
@kylesuss
Copy link
Collaborator

🚀 PR was released in v0.0.24 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants