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

Function restoreFocusToElement

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

Source from the content-addressed store, hash-verified

824}
825
826function restoreFocusToElement(node: FocusableElement) {
827 // Dispatch a custom event that parent elements can intercept to customize focus restoration.
828 // For example, virtualized collection components reuse DOM elements, so the original element
829 // might still exist in the DOM but representing a different item.
830 if (node.dispatchEvent(new CustomEvent(RESTORE_FOCUS_EVENT, {bubbles: true, cancelable: true}))) {
831 focusElement(node);
832 }
833}
834
835/**
836 * 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