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

Improve modal accessibility #1198

Merged
merged 2 commits into from
Mar 9, 2017
Merged

Improve modal accessibility #1198

merged 2 commits into from
Mar 9, 2017

Conversation

hursey013
Copy link
Member

Why: Using the tab key, focus could be moved outside of the modal into the background. This PR traps the focus inside the modal and automatically focuses the first interactive element.

screen recording 2017-03-09 at 12 18 pm

@hursey013 hursey013 self-assigned this Mar 9, 2017
**Why**: Using the tab key, focus could be moved outside of the modal into the background.  This PR traps the focus in the modal and automatically focuses the first interactive element.
@hursey013
Copy link
Member Author

One more note, this fix applies to all modals using the Modal object, which is everything except the session timeout modal, which is implemented a little bit different and will need to get refactored in a future PR.


body_element = page.find('body')
body_element.send_keys [:shift, :tab]
expect(page.evaluate_script('document.activeElement.innerText')).to eq(
Copy link
Contributor

Choose a reason for hiding this comment

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

would it make sense to also test that closing the modal does not "trap" the focus? I think that is what you are setting up when you have this.trap[showing ? 'activate' : 'deactivate'](); so would be good to have test coverage for that, too!

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, good point, will add.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jessieay added additional test to make sure focus is returned to the original element which is part of the deactivate function.

Copy link
Contributor

@el-mapache el-mapache left a comment

Choose a reason for hiding this comment

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

Looks good. Once you add the test that @jessieay suggested, feel free to merge.

**Why**: To ensure that focus is returned to the original element and is no longer inside the modal
Copy link
Contributor

@jessieay jessieay left a comment

Choose a reason for hiding this comment

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

🐵 🎉

@hursey013 hursey013 merged commit 739188e into master Mar 9, 2017
@jessieay jessieay deleted the bh-modal-a11y branch March 9, 2017 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants