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

Function focusFirst

packages/react-aria/src/focus/FocusScope.tsx:275–286  ·  view source on GitHub ↗
(opts = {})

Source from the content-addressed store, hash-verified

273 return previousNode;
274 },
275 focusFirst(opts = {}) {
276 let scope = scopeRef.current!;
277 let {tabbable, accept} = opts;
278 let scopeRoot = getScopeRoot(scope);
279 let walker = getFocusableTreeWalker(scopeRoot, {tabbable, accept}, scope);
280 walker.currentNode = scope[0].previousElementSibling!;
281 let nextNode = walker.nextNode() as FocusableElement;
282 if (nextNode) {
283 focusElement(nextNode, true);
284 }
285 return nextNode;
286 },
287 focusLast(opts = {}) {
288 let scope = scopeRef.current!;
289 let {tabbable, accept} = opts;

Callers 1

openPopupFunction · 0.85

Calls 4

getScopeRootFunction · 0.85
getFocusableTreeWalkerFunction · 0.85
focusElementFunction · 0.85
nextNodeMethod · 0.80

Tested by

no test coverage detected