Repository navigation
Description
Hello,
I would like to start using React, but am very concerned about the examples I am seeing. I would like to use React to interact with lots of data.
I am a screen reader user and Facebook has put out lots of articles on react’s accessibility:
https://code.facebook.com/posts/435862739941212/making-react-native-apps-accessible/
https://facebook.github.io/react-native/docs/accessibility.html
These are great, but strangely, the examples I have read that the React developers have put out are not accessible:
https://facebook.github.io/react/tutorial/tutorial.html
https://facebook.github.io/fixed-data-table/example-object-data.html
For the tutorial, there are several problems: First is that codepen is not very accessible, so seeing examples there is really difficult. Second, there is a huge number of buttons that have no text in them in the tic-tac-toe game. Third, there doesn’t seem to be any use of a table. If I remember correctly, a tic-tac-toe board is in a square. A 4 by 4 set of table boxes would really help in making a beautiful layout for screen reader users.
For the datatable, there is no table! I think this table is just div elements with CSS. Why? It says it is a table. To make this accessible, one needs to use the table tag, the th tag, the tr tag and the td tag. There is a fantastic article on how to make HTML tables:
http://webaim.org/techniques/tables/data
This is really scary for me because if developers are looking at the above examples and learning how to code from them, then they are learning how to code in an inaccessible manor. Not only does this mean that I can’t learn to use react from the official tutorial, but any developer who goes through the official tutorial will have been exposed to an app that is supposed to model how their apps should look like. If there apps look like the tutorial, I will basically not be able to use any app made with react best practices.
I’m really confused, if react does all the actual rendering, why are all the rendered elements not in perfect HTML? Accessibility is not the use of an API, in fact, an accessibility API just makes things more difficult for everyone by adding complexity into something that is super easy. The best way of making screen reader accessible apps is by using HTML tags, not including div or span. React has done an amazing thing by controlling HTML rendering and now all that needs to be done is make that renderer output proper HTML which will then be accessible.
If Facebook’s developers are not writing accessible apps by default, I think that there should be more reinforcement of good coding practices. Could there be a warning when a button is missing text in between the opening and closing tags? Could there be a warning when images do not have alt text? Could there be a warning when links don’t have text in between the opening and closing tags? Could the app throw an error when input boxes are not coupled with a label element? Could errors and warnings please be given by React when an app does not follow good coding practices?
This would not only help the React team make accessible examples, but it will help to insure an accessible web for me and the other 39000000 screen reader users in the world.
http://www.who.int/mediacentre/factsheets/fs282/en/
Please let me know how I can help.
Thank you!
Activity
gaearon commentedon Apr 28, 2017
Thanks for raising this! Do you know if there’s another online JS environment that is more accessible? Would it help if we provided the same code as a GitHub project you could download and run locally?
StommePoes commentedon May 1, 2017
@gaearon I've heard from other screen reader users that JSfiddle is more keyboard/screen reader accessible. I also remember Léonie Watson talking about this to Chris at CodePen, there's an open issue for a11y.
But also having demos running on githubpages (which some React projects do already) can also help. Plus, those can allow all developers to inspect the output in their browser(s) before doing all the npm-installing and local-server-running once they decide they want to tinker. Esp in my case often for some reason my phone won't run stuff I have on my local network (while all the laptops in the house are fine) so an external (githubpages for example) server can help devs with phones like mine view stuff on more browsers (I have no idea if the issue is my phone or what, just something I've noticed working on my own stuff at work).
frastlin commentedon May 1, 2017
@gaearon Yes, a Github would probably be best at this moment. I have been asking around on different blind programmer lists and so far, I have not found any online JS environment that is accessible. It is just because of the code editor. So frankly, I only use that site to see what the app should look like when it is finished. The tutorial should have all the code in finished form somewhere.
The code editor is really the least of the issues though. The lack of button or link names is much more important. I can't even see what a working example of the tutorial looks like. I just see a long line of "button". You could label the buttons like "blank Square" "O Square" and "X Square", then put the buttons into a table, rather than using CSS. Then it would be a whole lot more accessible. tic-tac-toe needs the square layout and the table element is the only way to get that for screen readers.
Thanks,
StommePoes commentedon May 7, 2017
Sorry my previous comment said "JS fiddle" but it was JSbin (excepting the edit box)
frastlin commentedon May 7, 2017
JSbin does have a better UX and is easier to use, but it doesn't really matter as both have the live examples that are pretty easy to see.
bvaughn commentedon Oct 8, 2017
That has actually been fixed since this issue was reported 👍
Please correct me if I'm wrong, but ARIA attributes are also a valid alternative to an actual HTML
<table>. Is this incorrect?The documentation and source code for reactjs.org now lives in a different repository: reactjs/reactjs.org. (For more info on why we made this move, see issue #11075.)
@flarnie has done some accessibility auditing for the new reactjs.org website but I'm sure we can still improve more. I'll create an issue in the new repo: reactjs/react.dev#78
Let's continue the discussion there! 😁
StommePoes commentedon Oct 10, 2017
Just to answer this question here since it was asked here:
"Please correct me if I'm wrong, but ARIA attributes are also a valid alternative to an actual HTML <table>. Is this incorrect?"
Technically valid but discouraged.
Since ARIA came out, some "rules of ARIA" have appeared to accompany ARIA use. The first rule of ARIA is, if there's native HTML that can carry the necessary semantics, use it over ARIA.
https://www.w3.org/TR/using-aria/#rule1
The reasons for this tend to be:
For those reasons, yes, technically a pile of divs with aria attributes and roles on damn near every tag could be allowed, technically accessible, and if done 100% correctly, the end user would not know the difference. But, ew. :)
bvaughn commentedon Oct 10, 2017
This seems like an important point. Admittedly it's one I'm not very familiar with.
By chance, do you have any references that show what support (percentages) is like? I'm curious to learn more.
On the other hand, this isn't a convincing argument to me. I can easily imagine scenarios where it's more work to use ARIA (eg like the button one you mentioned) and ones where it's less work to use ARIA (as is often the case with tables). The choice of which is better from a development and maintenance perspective should be case-by-case.
The w3 page you linked to says:
In my experience, this is generally the motivator when divs+ARIA roles are preferred over the traditional elements.
frastlin commentedon Oct 10, 2017
I will do an accessible version in a little bit, but is the look for a tutorial worth the massive complexity Aria brings to a project?
I know so many companies (big companies) who try and get away with using Aria, but one small problem and the whole table becomes unusable and if you are not using a screen reader, you would never know.
If one wishes to use aria it is imperative a screen reader user test it with several screen readers on several browsers. Using Aria is like you trying to do a version of CSS with completely new syntax and CSS without looking at the results.
Using HTML is using widgets that look fantastic out of the box. (It is incomprehensible to me that HTML widgets look so bad).
The buttons that the X and the O are on are not labeled. A trick is to copy and paste the webpage into a text document and what you see is pretty much what a screen reader sees. From the layout to the words. We get a little more, like edit fields say edit and buttons have the word "button" at the end, but the copy and paste method shows some of the worst errors.
frastlin commentedon Oct 10, 2017
BTW, the title should change and say the tutorial example is not accessible. The docs at:
https://reactjs.org/docs/hello-world.html
are beautiful. I have never read such amazing documentation for a Framework before. I don't even know why you need the tutorial if you have those Docs LOL.
bvaughn commentedon Oct 10, 2017
Hey @frastlin, let's continue this chat over on the new issue 😄
reactjs/react.dev/issues/78
This one's closed since the docs have been moved to a new repo.
StommePoes commentedon Oct 11, 2017
@bvaughn "The choice of which is better from a development and maintenance perspective should be case-by-case."
Yes. Though I haven't seen a fake-table-aria'd-up that was not more code than just a table, but with all things, YMMV.
Yes, and this is almost always about form controls, since browsers tend to disallow styling and the OS takes a big hand in styling. This is why we'll get an aria'd-up-the-wahoo dropdown where a <select> tag would have worked in more instances-- we can't style the options in most browsers and even styling the main body takes a bunch of hacks. This means though that the developer is now responsible for all the things a select would do automagically: collision detection, work in mobile OSes (dealing with onscreen OS-based keyboard appearing/disappearing), and they have to script in all the behaviours: https://www.w3.org/TR/wai-aria-practices-1.1/#menu
For a lot of teams, they're willing to do all that work because the default styles are too fugly and CSS can't do the job (even with shadow-dom this isn't looking like an option either).
A table is a harder sell, but again if a team is willing to add the extra code and tests and whatnot, it is indeed ultimately their decision. They will have to be more open to edge-case bug reports. Also I'll recommend the developers (while prototyping locally and as part of their tech stack before pushing) run accessibility testing tools that can catch things like mismatched ARIA parent/child roles (which roles can have which child roles or required parent roles) since that becomes a thing with structures like tables that get created purely with ARIA. And yeah, they might need to actually go test in a screen reader, since currently that's who's getting 99% of the benefit of ARIA (screen magnifiers and Dragon do a bit as well).
One place I have seen an interesting take on aria'd tables was a responsive table. Knowing that changing the CSS display states on a table removed the table semantics in several browsers (booo, firefox and safari, booo), I've seen a team use list markup, and ARIA at minimum screen sizes plus CSS to turn the list into a table for "desktop." At sizes too small to show a useful table, the ARIA roles are just removed and the user ends up with a semantic, if slightly complex, list. Was a weird but neat idea, anyway.
@frastlin "Using HTML is using widgets that look fantastic out of the box. (It is incomprehensible to me that HTML widgets look so bad)."
Oh, form controls can look pretty terrible :P
bvaughn commentedon Oct 11, 2017
Again, let's continue this chat over on the new issue: reactjs/react.dev/issues/78 😄