MCPcopy Index your code
hub / github.com/adobe/react-spectrum / restoreFocusToElement

Function restoreFocusToElement

packages/react-aria/src/focus/FocusScope.tsx:824–831  ·  view source on GitHub ↗
(node: FocusableElement)

Source from the content-addressed store, hash-verified

822}
823
824function restoreFocusToElement(node: FocusableElement) {
825 // Dispatch a custom event that parent elements can intercept to customize focus restoration.
826 // For example, virtualized collection components reuse DOM elements, so the original element
827 // might still exist in the DOM but representing a different item.
828 if (node.dispatchEvent(new CustomEvent(RESTORE_FOCUS_EVENT, {bubbles: true, cancelable: true}))) {
829 focusElement(node);
830 }
831}
832
833/**
834 * Create a [TreeWalker]{@link https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker}

Callers 1

useRestoreFocusFunction · 0.85

Calls 1

focusElementFunction · 0.85

Tested by

no test coverage detected