From 30bb8cfbeb6d970f3ed7829058df2c14deb5852f Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:08:39 +0700 Subject: [PATCH] Fix not able to loop around in some cases --- src/modules/stream/stream-settings.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/stream/stream-settings.ts b/src/modules/stream/stream-settings.ts index 3eef01a..775f04d 100644 --- a/src/modules/stream/stream-settings.ts +++ b/src/modules/stream/stream-settings.ts @@ -534,8 +534,9 @@ export class StreamSettings { } // If it's the first/last item -> loop around - const pseudo = direction === NavigationDirection.UP ? 'last-of-type' : 'first-of-type'; - const $target = this.$settings!.querySelector(`div[data-tab-group]:not(.bx-gone) div[data-focus-container]:${pseudo} [tabindex="0"]:last-of-type`); + // 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`); $target && ($target as HTMLElement).focus(); } else if (direction === NavigationDirection.LEFT || direction === NavigationDirection.RIGHT) { // Find all child elements with tabindex