diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index 868a75f4..4a2f882c 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -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();