graphql / graphiql

GraphiQL & the GraphQL LSP Reference Ecosystem for building browser & IDE tools.
MIT License
16.04k stars 1.72k forks source link

Improvements to Accessibility #3422

Open dinonuggies1 opened 1 year ago

dinonuggies1 commented 1 year ago

Hello, graphiql maintainers!

GitHub's API team provides an integrated client within GitHub's public web documentation for GraphQL. We're big fans of the tool, and use it as a means for integrators to become more familiar with our GraphQL schema. We've recently upgraded to the latest version of the graphiql package (3.0.5 as of September 18, 2023), and thereby many built in features of the client. This client is one of the most utilized aspects of the GraphQL doc set, so it's highly visible for visitors with GraphQL in mind.

Recently, we've placed a stronger focus on making our web experience more accessible as we strive to become the home for all developers. With that in mind, we believe there are a few improvements that would greatly enhance the experience of developers/users with varying disabilities. πŸŽ‰

Here are a few accessibility concerns identified by an internal audit here at GitHub:

  1. The elements of the Graphiql explorer pane are not focusable:

Image

In other words, when a user tabs through the explorer pane, each schema component/form element should be focusable

  1. The focus order is not logical:

Image

In this instance, the user tabs to the "History", hits enter, and instead of the next tab sequence stepping into the History view, the user is directed to the next button (The Explorer button).

  1. There isn't appropriate labels for the form elements of the GraphiQL Explorer pane (i.e: fields, queries, or mutation):

Image

Providing the right aria-label helps people who utilize screen readers.

  1. Form elements don't include the role attribute for the GraphiQL Explorer:

Image

** screen reader concern

  1. Missing associated label 'Add new' along with the query dropdown.

Image

** screen reader concern

  1. The luminosity ratio of the ' " _" ' should be greater than or equal to 4.5:1:

Image

** Update - September 27th, 2023

  1. The luminosity ratio for the text within the query editor and results pane doesn't meet the contrast ratio of 4.5:1 for the default light mode or dark mode (Although, Dark mode is closer πŸ‘πŸ½). I've taken a dive into each element of the query editor in hopes that it'll help shed light on the selectors that require adjustments. πŸ™πŸ½

With Default (Light) Theme

Screenshot 2023-09-25 at 3 20 20 PM

class foreground color - properties background color - query editor section contrast ratio Meets WCAG AA? background color - results section contrast ratio Meets WCAG AA?
.cm-s-graphiql .cm-keyword { color: hsl(var(--color-primary)) } #d60590 #ffffff 4.9:1 βœ… #f3f4f5 4.45:1 ❌
.cm-s-graphiql .cm-def { color: hsl(var(--color-tertiary)) } #009fb8 #ffffff 3.15:1 ❌ #f3f4f5 2.86:1 ❌
.cm-s-graphiql .cm-punctuation { color: hsla(var(--color-neutral),var(--alpha-tertiary)) } #3b4b68 alpha = .5 #ffffff 8.77:1 βœ… #f3f4f5 7.97:1 βœ…
.cm-s-graphiql .cm-variable { color: hsl(var(--color-secondary)) } #6c69ce #ffffff 4.61:1 βœ… #f3f4f5 4.19:1 ❌
.cm-s-graphiql .cm-atom { color: hsl(var(--color-tertiary)) } #009fb8 #ffffff 3.15:1 ❌ #f3f4f5 2.86:1 ❌
.cm-s-graphiql .cm-number { color: hsl(var(--color-success)) } #2bab7c #ffffff 2.9:1 ❌ #f3f4f5 2.64:1 ❌
.cm-s-graphiql .cm-string { color: hsl(var(--color-warning)) } #d17d00 #ffffff 3.16:1 ❌ #f3f4f5 2.86:1 ❌
.cm-s-graphiql .cm-builtin { color: hsl(var(--color-success)) } #2bab7c #ffffff 2.9:1 ❌ #f3f4f5 2.64:1 ❌
.cm-s-graphiql .cm-string-2 { color: hsl(var(--color-secondary)) } #6c69ce #ffffff 4.61:1 βœ… #f3f4f5 4.19:1 ❌
.cm-s-graphiql .cm-attribute,.cm-s-graphiql .cm-meta { color: hsl(var(--color-tertiary)) } #009fb8 #ffffff 3.15:1 ❌ #f3f4f5 2.86:1 ❌
.cm-s-graphiql .cm-property { color: hsl(var(--color-info)) } #007deb #ffffff 4.09:1 ❌ #f3f4f5 3.71:1 ❌
.cm-s-graphiql .cm-qualifier { color: hsl(var(--color-secondary)) } #6c69ce #ffffff 4.61:1 βœ… #f3f4f5 4.19:1 ❌
.cm-s-graphiql .cm-comment { color: hsla(var(--color-neutral),var(--alpha-secondary)) } #3b4b68 alpha = .76 #ffffff 8.77:1 βœ… #f3f4f5 7.97:1 βœ…
.cm-s-graphiql .cm-ws { color: hsla(var(--color-neutral),var(--alpha-tertiary)) } #3b4b68 alpha = .5 #ffffff 8.77:1 βœ… #f3f4f5 7.97:1 βœ…
.cm-s-graphiql .cm-invalidchar { color: hsl(var(--color-error)) } #f85b30 #ffffff 3.21:1 ❌ #f3f4f5 2.92:1 ❌

With Dark Mode Theme

Screenshot 2023-09-25 at 3 22 17 PM

class foreground color - properties background color - query editor section contrast ratio Meets WCAG AA? background color - results section contrast ratio Meets WCAG AA?
.cm-s-graphiql .cm-keyword { color: hsl(var(--color-primary)) } #ff5794 #212a3b 4.82:1 βœ… #2D3647 4.07:1 ❌
.cm-s-graphiql .cm-def { color: hsl(var(--color-tertiary)) } #00c2e0 #212a3b 6.71:1 βœ… #2D3647 5.65:1 βœ…
.cm-s-graphiql .cm-punctuation { color: hsla(var(--color-neutral)) } #b7c2d7 #212a3b 8.02:1 βœ… #2D3647 6.76:1 βœ…
.cm-s-graphiql .cm-variable { color: hsl(var(--color-secondary)) } #908aff #212a3b 4.97:1 βœ… #2D3647 4.19:1 ❌
.cm-s-graphiql .cm-atom { color: hsl(var(--color-tertiary)) } #00c2e0 #212a3b 6.71:1 βœ… #2D3647 5.65:1 βœ…
.cm-s-graphiql .cm-number { color: hsl(var(--color-success)) } #00d688 #212a3b 7.52:1 βœ… #2D3647 6.34:1 βœ…
.cm-s-graphiql .cm-string { color: hsl(var(--color-warning)) } #ffcc99 #212a3b 9.83:1 βœ… #2D3647 8.29:1 βœ…
.cm-s-graphiql .cm-builtin { color: hsl(var(--color-success)) } #00d688 #212a3b 7.52:1 βœ… #2D3647 6.34:1 βœ…
.cm-s-graphiql .cm-string-2 { color: hsl(var(--color-secondary)) } #908aff #212a3b 4.97:1 βœ… #2D3647 4.19:1 ❌
.cm-s-graphiql .cm-attribute,.cm-s-graphiql .cm-meta { color: hsl(var(--color-tertiary)) } #00c2e0 #212a3b 6.71:1 βœ… #2D3647 5.65:1 βœ…
.cm-s-graphiql .cm-property { color: hsl(var(--color-info)) } #70bcff #212a3b 7.07:1 βœ… #2D3647 5.96:1 βœ…
.cm-s-graphiql .cm-qualifier { color: hsl(var(--color-secondary)) } #908aff #212a3b 4.97:1 βœ… #2D3647 4.19:1 ❌
.cm-s-graphiql .cm-comment { color: hsla(var(--color-neutral)) } #b7c2d7 #212a3b 8.02:1 βœ… #2D3647 6.76:1 βœ…
.cm-s-graphiql .cm-ws { color: hsla(var(--color-neutral)) } #b7c2d7 #212a3b 8.02:1 βœ… #2D3647 6.76:1 βœ…
.cm-s-graphiql .cm-invalidchar { color: hsl(var(--color-error)) } #ff5729 #212a3b 4.55:1 βœ… #2D3647 3.84:1 ❌

As you can see, most of our accessibility findings stem from the GraphQL Explorer feature, or more specifically, the @graphiql/explorer-plugin package. It could be that these concerns have been addressed in more recent versions of the explorer, however, we encountered some issues upgrading to the latest graphiql package with the explorer package included. We did have success upgrading to version 0.1.4 of the explorer plugin along with 2.0.7 of the graphiql package, but noticed that the same issues remained. If it's confirmed that the above has been addressed in later versions of the explorer plugin, we'd be happy to invest more time into the upgrade, but for the moment, we've decided to omit the explorer feature from the client given the accessibility concerns above.

Lastly, thanks for all the hard work you've put into making this a great tool! πŸ™

Timmmy-nlb commented 11 months ago

I would also be happy if the current version is revised and improved again. In the current state, it is simply only aggravated and the simple / fast usability is no longer given.

see too:

https://github.com/orgs/community/discussions/72715#discussioncomment-7408457

grafik

acao commented 11 months ago

@dinonuggies1 thank you for this! are you able to do a similar audit of graphiql@2? unfortunately we aren't able to backport these fixes to 1.x because it was a substantial rewrite, and we haven't had a 1.x release in a few years. most of this still applies where the third party explorer is concerned. I have a PR open (#3374) to adopt the explorer into our repo so we can make many of these improvements!

heiskr commented 10 months ago

@acao I believe the GitHub Accessibility team uses https://www.deque.com/axe/devtools/chrome-browser-extension/ to identify accessibility issues.

acao commented 10 months ago

So, we will be rebuilding the explorer components and plugin in the coming months. We did not get permission to inherit the project from the current IP owner, and the original authors are suggesting a rewrite anyways.

A GraphQL Foundation grant came through for someone to work on this explorer rebuild, and we will know if they still can work on it soon.

Until then, I hope to take care of these items this month myself:

  1. the 5-10% of items in this list that are not part of the third party graphiql-explorer components
  2. any CSS overrides that resolve any of the above issues for graphiql-explorer that can ship via the plugin until the rewrite occurs.

If you would like to help with the explorer rewrite, join us on the discord in the readme!

xrstf commented 2 months ago

Are there any news on this? At the moment the current "explorer" is basically useless to build up queries. What is the alternative I'm supposed to use at the moment?