Apply review suggestion

This commit is contained in:
Joachim 2021-11-28 21:46:32 +01:00
parent bf5cb898ef
commit 9ec4ad6b31

View file

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