summaryrefslogtreecommitdiff
path: root/src/client/scripts/focus.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/scripts/focus.ts')
-rw-r--r--src/client/scripts/focus.ts12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/client/scripts/focus.ts b/src/client/scripts/focus.ts
index a2a8516d36..0894877820 100644
--- a/src/client/scripts/focus.ts
+++ b/src/client/scripts/focus.ts
@@ -1,21 +1,25 @@
-export function focusPrev(el: Element | null, self = false) {
+export function focusPrev(el: Element | null, self = false, scroll = true) {
if (el == null) return;
if (!self) el = el.previousElementSibling;
if (el) {
if (el.hasAttribute('tabindex')) {
- (el as HTMLElement).focus();
+ (el as HTMLElement).focus({
+ preventScroll: !scroll
+ });
} else {
focusPrev(el.previousElementSibling, true);
}
}
}
-export function focusNext(el: Element | null, self = false) {
+export function focusNext(el: Element | null, self = false, scroll = true) {
if (el == null) return;
if (!self) el = el.nextElementSibling;
if (el) {
if (el.hasAttribute('tabindex')) {
- (el as HTMLElement).focus();
+ (el as HTMLElement).focus({
+ preventScroll: !scroll
+ });
} else {
focusPrev(el.nextElementSibling, true);
}