MCPcopy
hub / github.com/adobe/react-spectrum / focusFirst

Function focusFirst

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

Source from the content-addressed store, hash-verified

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