Skip to content

Commit

Permalink
fix: trap tab focus in modal when hitting s-tab (#4075)
Browse files Browse the repository at this point in the history
Pretend that the modal dialog is equivalent to the first
focusable/tabbable element when hitting shift-tab.

Fix #4049
  • Loading branch information
gkatsev authored Feb 21, 2017
1 parent 0d0dea4 commit 1f7a842
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/js/modal-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ class ModalDialog extends Component {
}
}

if (document.activeElement === this.el_) {
focusIndex = 0;
}

if (event.shiftKey && focusIndex === 0) {
focusableEls[focusableEls.length - 1].focus();
event.preventDefault();
Expand Down

0 comments on commit 1f7a842

Please sign in to comment.