Skip to content

Improve accessibility, fixes #359 #570

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

Merged
merged 2 commits into from
Nov 30, 2017
Merged

Conversation

sheerun
Copy link
Contributor

@sheerun sheerun commented Nov 29, 2017

  • adds aria-modal="true" to modal portal
  • doesn't make body a default appElement
  • warns if appElement is not set in any way

Fixes #359

Acceptance Checklist:

  • All commits have been squashed to one.
    Unnecesary rule: You can squash with button when merging
  • The commit message follows the guidelines in CONTRIBUTING.md.
    Unnecessary rule: You can edit commit message as well :)
  • Documentation (README.md) and examples have been updated as needed.
  • If this is a code change, a spec testing the functionality has been added.
  • If the commit message has [changed] or [removed], there is an upgrade path above.

@sheerun
Copy link
Contributor Author

sheerun commented Nov 29, 2017

I've updated the readme as well

@sheerun
Copy link
Contributor Author

sheerun commented Nov 29, 2017

Also fixed prettier issues

@sheerun
Copy link
Contributor Author

sheerun commented Nov 29, 2017

also satisfied eslint

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 86.341% when pulling 7c36750 on sheerun:accessibility into 700eb4e on reactjs:master.

@diasbruno
Copy link
Collaborator

Fantastic! I have to finish the review later, but I'll make sure we release this ASAP.

@diasbruno
Copy link
Collaborator

Running some tests, everything looks great. The only question I have is making setAppElement required.

react-modal has become more flexible in terms of accessibility, like a user may want to disable some a11y feature on a edge case...so, one option is to not set aria-hidden if appElement is not defined.

We could write a log message, on dev mode, explaining why not defining appElement it is bad.

Any thoughts?

- adds aria-modal="true" to modal portal
- doesn't make body a default appElement
- warns if appElement is not set in any way
@sheerun
Copy link
Contributor Author

sheerun commented Nov 30, 2017

@diasbruno I didn't make setAppElement required. I just show a warning if it's not set.

I also updates PR so it doesn't show warning in production, tells how to opt-out with ariaHideApp and tells why setting this is necessary for accessibility. The message says now:

        "react-modal: App element is not defined.",
        "Please use `Modal.setAppElement(el)` or set `appElement={el}`.",
        "This is needed so screen reades don't see main content when modal is opened.",
        "It is not recommended, but you can opt-out by setting `ariaHideApp={false}`."

@diasbruno
Copy link
Collaborator

Oh, ok...what about the second part (don't set aria-hidden if appElement is not defined)? Having ariaHideApp={false} is great, but it will require users to fix their code (breaking change). Any ideas?

@sheerun
Copy link
Contributor Author

sheerun commented Nov 30, 2017

@diasbruno As I said it's not a breaking change as it only shows a warning, and only in development.

@diasbruno
Copy link
Collaborator

Ah, ok. It will be noop in this case.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 86.441% when pulling 123b5f1 on sheerun:accessibility into 700eb4e on reactjs:master.

@diasbruno
Copy link
Collaborator

Sorry, I wasn't paying attention to this case. I was think on something more explicit like appElement != null && ariaHideApp, but this way looks better.

@sheerun
Copy link
Contributor Author

sheerun commented Nov 30, 2017

There is:

    if (ariaHideApp) {
      ariaAppHider.hide(appElement);
    }

but feel free to change it (this PR is editable by you). It seems artificial to me to pass ariaHideApp variable to show/hide, just to do simple && ariaHideApp

@diasbruno diasbruno self-requested a review November 30, 2017 12:37
@diasbruno diasbruno merged commit 38dc8f9 into reactjs:master Nov 30, 2017
@diasbruno
Copy link
Collaborator

Thank you so much @sheerun!

@diasbruno
Copy link
Collaborator

Release v3.1.6.

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.

3 participants