Merge pull request #1675 from Laerdal/focus-trap-only-fullscreen

Trap keyboard focus only when fullscreen
This commit is contained in:
Sam Potts 2020-02-08 22:18:59 +00:00 committed by GitHub
commit f00c279366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -257,10 +257,11 @@ export function trapFocus(element = null, toggle = false) {
const focusable = getElements.call(this, 'button:not(:disabled), input:not(:disabled), [tabindex]');
const first = focusable[0];
const last = focusable[focusable.length - 1];
const player = this;
const trap = event => {
// Bail if not tab key or not fullscreen
if (event.key !== 'Tab' || event.keyCode !== 9) {
if (event.key !== 'Tab' || event.keyCode !== 9 || !player.fullscreen.active) {
return;
}