Loop around settings

This commit is contained in:
redphx
2024-07-18 17:30:34 +07:00
parent fbebb12965
commit daf3f72736
2 changed files with 13 additions and 4 deletions

View File

@@ -476,6 +476,11 @@ export class StreamSettings {
$sibling && $sibling.focus();
return;
}
// If it's the first/last item -> loop around
const pseudo = direction === NavigationDirection.UP ? 'last-of-type' : 'first-of-type';
const $target = this.$tabs!.querySelector(`svg:not(.bx-gone):${pseudo}`);
$target && ($target as HTMLElement).focus();
} else if (direction === NavigationDirection.RIGHT) {
this.#focusFirstVisibleSetting();
}
@@ -513,6 +518,11 @@ export class StreamSettings {
return;
}
}
// 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`);
$target && ($target as HTMLElement).focus();
} else if (direction === NavigationDirection.LEFT || direction === NavigationDirection.RIGHT) {
// Find all child elements with tabindex
const children = Array.from($parent.querySelectorAll('[tabindex="0"]'));