From 1d590103ce04a0d3abadc1a36feda677783754d0 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sat, 20 Jul 2024 05:52:55 +0700 Subject: [PATCH] Fix not able to scroll pass hidden settings --- src/modules/stream/stream-settings.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/stream/stream-settings.ts b/src/modules/stream/stream-settings.ts index 775f04d..06a188f 100644 --- a/src/modules/stream/stream-settings.ts +++ b/src/modules/stream/stream-settings.ts @@ -529,14 +529,18 @@ export class StreamSettings { const $childSetting = $sibling.querySelector('[tabindex="0"]:last-of-type') as HTMLElement; if ($childSetting) { $childSetting.focus(); - return; + + // Only stop when it was focused successfully + if (document.activeElement === $childSetting) { + return; + } } } // If it's the first/last item -> loop around // TODO: bugged if pseudo is "first-of-type" and the first setting is disabled const pseudo = direction === NavigationDirection.UP ? ':last-of-type' : ''; - const $target = this.$settings!.querySelector(`div[data-tab-group]:not(.bx-gone) div[data-focus-container]${pseudo} [tabindex="0"]:not(:disabled):last-of-type`); + const $target = this.$settings!.querySelector(`div[data-tab-group]:not(.bx-gone) div[data-focus-container]:not(.bx-gone)${pseudo} [tabindex="0"]:not(:disabled):last-of-type`); $target && ($target as HTMLElement).focus(); } else if (direction === NavigationDirection.LEFT || direction === NavigationDirection.RIGHT) { // Find all child elements with tabindex