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

[EuiModal] Accessibility #502

Closed
cjcenizal opened this issue Mar 12, 2018 · 3 comments
Closed

[EuiModal] Accessibility #502

cjcenizal opened this issue Mar 12, 2018 · 3 comments

Comments

@cjcenizal
Copy link
Contributor

From elastic/kibana#11823.

We need to make sure our modals are keyboard- and screen-reader-accessible. For the full breakdown, see https://www.marcozehe.de/2015/02/05/advanced-aria-tip-2-accessible-modal-dialogs/.

Here's an example of some of the markup we need:

<div role="dialog" aria-labelledby="modalTitle" aria-describedby="modalDescription">
  <div id="modalTitle">Save "untitled" document?</div>
  <div id="modalDescription">You have made changes to "untitled.txt" that have not been saved. What do you want to do?</div>
  <button type="button">Save changes</button>
  <button type="button">Discard changes</button>
  <button type="button">Cancel</button>
</div>

Here are the crib notes:

  • Add role="dialog" to the Modal root element.
  • Use aria-labelledby and aria-describedby to point screen readers to the title and body text of the modal.
  • When the modal is opened, focus on the first tabbable element.
  • Use JS to trap tabbing within the modal. Add keypress handlers to the first and last tabbable elements so that tabbing from the last element focuses on the first one, and shift-tabbing from the first element focuses on the last one.
  • Add an ESC keypress handler, so hitting escape closes the modal.
  • When the modal is closed, use JS to restore focus to the element which was last focused (this should be the button which was clicked to open the modal).
@myasonik
Copy link
Contributor

myasonik commented Sep 5, 2019

Adding onto here for when we get around to fixing modals: we should also probably upgrade our focus trapping (at least on modals but probably on other things too) to use react-focus-on instead of react-focus-lock which we currently use. (Explanation as to why is in the react-focus-on readme.

@chandlerprall
Copy link
Contributor

🎯The final solution for WAI ARIA compatible modal dialogs or full-screen tasks.

🤣🎢

For people who don't click through to react-focus-on, it is react-focus-lock plus

  • disables page scroll and user interactions using react-remove-scroll
  • hides rest of a page from screen-readers using aria-hidden

@myasonik myasonik mentioned this issue Sep 6, 2019
9 tasks
@cchaos cchaos changed the title Accessibility: Modals [EuiModal] Accessibility Mar 18, 2020
@cchaos cchaos added the meta label Mar 18, 2020
@chandlerprall
Copy link
Contributor

At least some of the changes mentioned here have been applied, and the rest are now being tracked in #3889

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants