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

Function focusFirst

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

Source from the content-addressed store, hash-verified

257 return previousNode;
258 },
259 focusFirst(opts = {}) {
260 let scope = scopeRef.current!;
261 let {tabbable, accept} = opts;
262 let scopeRoot = getScopeRoot(scope);
263 let walker = getFocusableTreeWalker(scopeRoot, {tabbable, accept}, scope);
264 walker.currentNode = scope[0].previousElementSibling!;
265 let nextNode = walker.nextNode() as FocusableElement;
266 if (nextNode) {
267 focusElement(nextNode, true);
268 }
269 return nextNode;
270 },
271 focusLast(opts = {}) {
272 let scope = scopeRef.current!;
273 let {tabbable, accept} = opts;

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected