MCPcopy
hub / github.com/adobe/react-spectrum / focusElement

Function focusElement

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

Source from the content-addressed store, hash-verified

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

Callers 7

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

Calls 2

focusSafelyFunction · 0.90
focusMethod · 0.80

Tested by

no test coverage detected