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

Function restoreFocusToElement

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

Source from the content-addressed store, hash-verified

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