diff --git a/inline-module-9e804879e37a77d0185feb25684c241c.js b/inline-module-9e804879e37a77d0185feb25684c241c.js index dcc9c14..5ac2f9d 100644 --- a/inline-module-9e804879e37a77d0185feb25684c241c.js +++ b/inline-module-9e804879e37a77d0185feb25684c241c.js @@ -523,7 +523,12 @@ class Trap { const addition = this.tabDirection === 'forward' ? 1 : -1; + let count = 0; while(true) { + if (count >= tabbableElements.length) { + break + } + if (currentFocusIndex + addition >= tabbableElements.length) { currentFocusIndex = 0; } else if (currentFocusIndex + addition < 0) { @@ -552,9 +557,11 @@ class Trap { this.currentFocus?.focus({ preventScroll: this.preventScroll }); // @ts-expect-error - if ([...activeElements()].includes(this.currentFocus)) { + if (![...activeElements()].includes(this.previousFocus)) { break } + + count++; } }