MCPcopy Create free account
hub / github.com/adobe/react-spectrum / focusElement

Function focusElement

packages/react-aria/src/focus/FocusScope.tsx:541–555  ·  view source on GitHub ↗
(element: FocusableElement | null, scroll = false)

Source from the content-addressed store, hash-verified

539}
540
541function focusElement(element: FocusableElement | null, scroll = false) {
542 if (element != null && !scroll) {
543 try {
544 focusSafely(element);
545 } catch {
546 // ignore
547 }
548 } else if (element != null) {
549 try {
550 element.focus();
551 } catch {
552 // ignore
553 }
554 }
555}
556
557function getFirstInScope(scope: Element[], tabbable = true): FocusableElement | null {
558 let sentinel = scope[0].previousElementSibling!;

Callers 9

focusNextFunction · 0.85
focusPreviousFunction · 0.85
focusFirstFunction · 0.85
focusLastFunction · 0.85
onKeyDownFunction · 0.85
onFocusFunction · 0.85
onBlurFunction · 0.85
focusFirstInScopeFunction · 0.85
restoreFocusToElementFunction · 0.85

Calls 2

focusSafelyFunction · 0.90
focusMethod · 0.80

Tested by

no test coverage detected