Automattic/jetpack — pull request #1115 by chrisdc (2014-09-13 18:28:55+00:00)
Title: Make module actions in the modal tab accessible

Hello, this pull request addresses issue #1013. In order to make the modal windows tab accessible it add the following actions:

## On opening a modal window

1. Save the currently focused element to the variable originPoint
2. Add `tabindex=0` to the modal window
3. Switch focus to the modal window

## On closing a modal window

1. Switch focus back to the element saved in originPoint
2. Remove the tabindex from the modal window

In addition I have also taken the following steps to aid accessibility (could be removed if people think they are not needed):

1. Added a hidden .screen-reader-text span at the top of the modal. This lets uses with screen readers know how to close the window.
2. Added an aria label to the close link to make it's function clearer for screen readers.

## Notes

1. Currently the modal window doesn't tab focus, it's possible for the user to tab back onto background elements while it's still focused
2. At the moment focus is shifted to and from the modal window whether the user uses the mouse or keyboard. I thought that this was the most useful approach in case anyone combines control methods, but I would be interested to hear other opinions on this.