gitea push
This commit is contained in:
+6
-6
@@ -411,21 +411,21 @@ export function getNextElement(elements, location, condition) {
|
||||
} while ((!_el || _el.offsetParent == null || !(condition?.(_el) ?? true)) && idx < elements.length && idx >= 0);
|
||||
return _el;
|
||||
}
|
||||
export function focusChild(el, location) {
|
||||
export function focusChild(el, location, options) {
|
||||
const focusable = focusableChildren(el);
|
||||
if (location == null) {
|
||||
if (el === document.activeElement || !el.contains(document.activeElement)) {
|
||||
focusable[0]?.focus();
|
||||
focusable[0]?.focus(options);
|
||||
}
|
||||
} else if (location === 'first') {
|
||||
focusable[0]?.focus();
|
||||
focusable[0]?.focus(options);
|
||||
} else if (location === 'last') {
|
||||
focusable.at(-1)?.focus();
|
||||
focusable.at(-1)?.focus(options);
|
||||
} else if (typeof location === 'number') {
|
||||
focusable[location]?.focus();
|
||||
focusable[location]?.focus(options);
|
||||
} else {
|
||||
const _el = getNextElement(focusable, location);
|
||||
if (_el) _el.focus();else focusChild(el, location === 'next' ? 'first' : 'last');
|
||||
if (_el) _el.focus();else focusChild(el, location === 'next' ? 'first' : 'last', options);
|
||||
}
|
||||
}
|
||||
export function isEmpty(val) {
|
||||
|
||||
Reference in New Issue
Block a user