Apply review suggestion

This commit is contained in:
Joachim 2021-11-28 21:46:32 +01:00
parent bf5cb898ef
commit 9ec4ad6b31
1 changed files with 4 additions and 4 deletions

View File

@ -420,6 +420,10 @@ let BookWyrm = new class {
} }
function handleFocusTrap(event) { function handleFocusTrap(event) {
if (event.key !== 'Tab') {
return;
}
const focusableEls = event.currentTarget.querySelectorAll( const focusableEls = event.currentTarget.querySelectorAll(
[ [
'a[href]:not([disabled])', 'a[href]:not([disabled])',
@ -434,10 +438,6 @@ let BookWyrm = new class {
const firstFocusableEl = focusableEls[0]; const firstFocusableEl = focusableEls[0];
const lastFocusableEl = focusableEls[focusableEls.length - 1]; const lastFocusableEl = focusableEls[focusableEls.length - 1];
if (event.key !== 'Tab') {
return;
}
if (event.shiftKey ) /* Shift + tab */ { if (event.shiftKey ) /* Shift + tab */ {
if (document.activeElement === firstFocusableEl) { if (document.activeElement === firstFocusableEl) {
lastFocusableEl.focus(); lastFocusableEl.focus();