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

Function focusElement

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

Source from the content-addressed store, hash-verified

523}
524
525function focusElement(element: FocusableElement | null, scroll = false) {
526 if (element != null && !scroll) {
527 try {
528 focusSafely(element);
529 } catch {
530 // ignore
531 }
532 } else if (element != null) {
533 try {
534 element.focus();
535 } catch {
536 // ignore
537 }
538 }
539}
540
541function getFirstInScope(scope: Element[], tabbable = true) {
542 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