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

Initial accessibility improvents and set up Eslint jsx-a11y plugin #5365

Closed
wants to merge 50 commits into from

Conversation

rafawendel
Copy link
Member

@rafawendel rafawendel commented Jan 21, 2021

What type of PR is this? (check all applicable)

  • Feature

Description

This aims to add the referred plugin, set up the appropriate rules and fix current suggestions.

After this PR the following standards should be met:

  • Links that look like links: <Link> - Renders <a>
  • Buttons that look like buttons: <Button> - Renders Antd <Button>
  • Links that look like buttons: <Link.Button> - Renders Antd <Button>, which is rendered as an <a>
  • Text Buttons "buttons that look like links": <PlainButton> - Renders styleless <button>

Todos (might be moved to another PR)

  • Add tabindex to appropriate components
  • Create custom link to abstract a11y behavior
  • Create a component to act as a plain button
  • Properly set role attributes

@rafawendel rafawendel force-pushed the add-eslint-jsx-a11y-plugin branch from eeb5048 to 7eff1e1 Compare January 25, 2021 18:49
@rafawendel rafawendel self-assigned this Jan 26, 2021
@rafawendel rafawendel changed the title Set up Eslint jsx-a11y plugin Initial accessibility improvents and set up Eslint jsx-a11y plugin Feb 1, 2021
Copy link

@thielium thielium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! a11y is huge and often underappreciated.

I'd like to understand a little more the reasoning behind some of the roles and things. I feel like some of them could be changed or altered -- I tried not to clutter the PR with redundant comments if I came across the same issue more than a couple times.

@@ -20,6 +21,8 @@ module.exports = {
// allow debugger during development
"no-debugger": process.env.NODE_ENV === "production" ? 2 : 0,
"jsx-a11y/anchor-is-valid": "off",
"jsx-a11y/no-autofocus": "off",
"jsx-a11y/click-events-have-key-events": "off", // TODO: create a wrapper for key events
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an issue tracking this TODO?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet. It might not be needed depending on how far we are moving into the a11y issue.

@rafawendel rafawendel force-pushed the add-eslint-jsx-a11y-plugin branch from 885c2f2 to 09f606e Compare February 4, 2021 13:05
Copy link

@thielium thielium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a time-boxed audit of https://deploy-preview-5365--redash-preview.netlify.app/alerts

Accessibility Insights for Web

  • Homepage: There are still some issues, but they don't appear to touch the parts of the app you've started with.
  • Other pages: Still a bunch of warnings and things. I think the plugin is a great start, but it definitely doesn't cover all of our usages.

Manual Testing

  • Tabbing around the main menu is pretty good. The Create button, since it has the ant popover menu, isn't accessible, and that's pretty frustrating (but we've already discussed it). Might be out of scope for round 1.
  • EditInPlace also has a click handler, and should be focusable (the same way the link form is focusable).
  • Got some complaints on the menuitem roles -- I think any menuitem that isn't a child of a menu or menubar is going to be upset (and in our case, I think it's happening when links have a menuitem role within the Menu.Item component). Tabbing around QueryControlDropdown wasn't too bad, though! Could use higher contrast when focused, but it worked.

There's more, but I think you get the idea: I think this is a reasonable first increment once the comments are addressed. Nice!

@rafawendel rafawendel force-pushed the add-eslint-jsx-a11y-plugin branch from 24bbe1b to 3aa2f66 Compare February 10, 2021 23:46
@kravets-levko
Copy link
Collaborator

@rafawendel Please keep an eye on Percy snapshots: this PR shouldn't affect the UI

Copy link

@thielium thielium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the blast radius of this PR is growing, and we've got a lot of voices in the room. I agree with @kravets-levko 's concerns, but I don't have too much more to add at this point. If it's good with him, it's good with me.

To be honest, I think the best possible approach, here, would be to split this PR up into small (<100 lines) PRs that tackle a single thing in each PR (menu / menu item roles, adding an accessiblility component, using that accessibility component, etc.). It's up to you, but I'm worried that there's enough here that we'll end up having a lot of long discussions while the uncontroversial parts stay unmerged.

@@ -71,9 +72,9 @@ export default function DesktopNavbar() {
const canCreateAlert = currentUser.hasPermission("list_alerts");

return (
<div className="desktop-navbar">
<nav className="desktop-navbar" role="navigation">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nav shouldn't need an additional role.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually recommended by WAI ARIA, as navs are not supported in older browsers. Of course this is questionable, since these are not under our supported browsers. I'll just remove it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good news is that jsx/a11y actually enforces this behavior (try adding a role="link" to an anchor 🤠)

@rafawendel rafawendel force-pushed the add-eslint-jsx-a11y-plugin branch from 55e9357 to 68e8676 Compare February 12, 2021 21:44
@@ -52,9 +52,9 @@ function AddToDashboardDialog({ dialog, visualization }) {
notification.success(
"Widget added to dashboard",
<React.Fragment>
<Link href={`${dashboard.url}`} onClick={() => notification.close(key)}>
<Button type="link" href={`${dashboard.url}`} onClick={() => notification.close(key)}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure about semantics of this component. On the one hand, it's link, on the other - it's button. But for me it looks that link role is primary (as if you click it - it will bring you to a dashboard page), and onClick action is secondary (just to hide irrelevant UI). So my suggestion is to revert it to Link

This was referenced Feb 25, 2021
@rafawendel rafawendel closed this Feb 25, 2021
@guidopetri guidopetri deleted the add-eslint-jsx-a11y-plugin branch July 22, 2023 03:15
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.

4 participants