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

Feat/add textarea label wcag 2.1 #104

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

TheeMattOliver
Copy link

@TheeMattOliver TheeMattOliver commented Nov 1, 2022

Closes #103

Problem

Projects that list react-simple-code-editor as a dependent violate WCAG Success Criterion 4.1.2: Name, Role, Value.

Screen Shot 2022-11-01 at 9 47 16 AM

For more context, please see issue #103 here.

Solution

I'd like to propose that we improve the accessibility of react-simple-code-editor with this PR, a small change that adds a textareaTitle prop to the rendered textarea. This strategy is proposed as part of the W3C official Techniques for WCAG 2.2. If others have better ideas please let me know!

Under this change, the textarea no longer violates WCAG Success Criterion 4.1.2, and authors may then judge whether their specific context requires a visual label during a manual accessibility review.

Screen Shot 2022-11-01 at 9 46 01 AM

Open questions

It's unclear to me how consumers can provide this prop. A default prop should suffice. Please let me know what ideas you have.

@oliviertassinari
Copy link
Collaborator

oliviertassinari commented Nov 15, 2022

I have noticed the same issue on https://mui.com/material-ui/react-alert/ since mui/material-ui#34870

Screenshot 2022-11-15 at 23 12 13

https://chrome.google.com/webstore/detail/wave-evaluation-tool/jbbplnpkjmmeebjpijfedlgcdilocofh

Maybe it would be simpler if we allow developers to apply anything they wish on the <textarea>.

@satya164
Copy link
Collaborator

Maybe it would be simpler if we allow developers to apply anything they wish on the <textarea>

One concern would be that it might be easy to break the editor if there are some props that alter styling of the text area or conflict with the props we need to pass internally.

@oliviertassinari
Copy link
Collaborator

oliviertassinari commented Nov 21, 2022

it might be easy to break the editor if there are some props that alter styling of the text area or conflict with the props we need to pass internally.

@satya164 Definitely, I think that it's about what dimension we want to value most. I would lean slightly toward the option that gives extra flexibility but happy either way.

(I'm biased by 1. not wanting to make a PR each time I need to extend something 2. I can read the codebase to figure out if it's a safe extension 3. I gave up on MUI trying to limit access to the elements.)

@satya164
Copy link
Collaborator

not wanting to make a PR each time I need to extend something

I think so far there haven't been many cases like this..

If we want to remove the current text area props and accept some object to pass to the text area instead, it'll be a breaking change so imo we should only do it if we really need to, e.g. we receive more of such PRs/requests.

@oliviertassinari
Copy link
Collaborator

oliviertassinari commented Nov 30, 2022

I think so far there haven't been many cases like this.

@satya164 There are multiple ways to fix the a11y issue reported here https://www.w3.org/WAI/tutorials/forms/labels/. 4 of them:

  • title attribute, the solution proposed by @TheeMattOliver
  • id attribute + label for. Already possible
  • aria-label attribute. Not possible
  • aria-labelledby attribute. Not possible

Personally, I would like to use aria-label to not have to render another DOM node and for the label to be screenreader only. I wouldn't want to use title as I don't want the tooltip.

@JustinTime42
Copy link

I see this is a pretty old issue and I'm not sure what the desired direction is. I needed a fix for my own use, though, so I forked the repo and resolved the a11y errors using an aria-label. Just submitted #118 in case that's helpful.

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.

a11y: "Form control element <textarea> has no associated label"
4 participants