Created
April 8, 2018 23:20
-
-
Save chris-pearce/64ce0a8a95f16e19f0e0ea189e16e9c5 to your computer and use it in GitHub Desktop.
Simple focus trap using `focusin` event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('focusin', () => { | |
if (!modal.contains(document.activeElement) { | |
firstModalFocusable.focus(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment