MCPcopy Index your code
hub / github.com/adobe/react-spectrum / focusNext

Function focusNext

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

Source from the content-addressed store, hash-verified

220function createFocusManagerForScope(scopeRef: React.RefObject<Element[] | null>): FocusManager {
221 return {
222 focusNext(opts: FocusManagerOptions = {}) {
223 let scope = scopeRef.current!;
224 let {from, tabbable, wrap, accept} = opts;
225 let node = from || getActiveElement(getOwnerDocument(scope[0] ?? undefined))!;
226 let sentinel = scope[0].previousElementSibling!;
227 let scopeRoot = getScopeRoot(scope);
228 let walker = getFocusableTreeWalker(scopeRoot, {tabbable, accept}, scope);
229 walker.currentNode = isElementInScope(node, scope) ? node : sentinel;
230 let nextNode = walker.nextNode() as FocusableElement;
231 if (!nextNode && wrap) {
232 walker.currentNode = sentinel;
233 nextNode = walker.nextNode() as FocusableElement;
234 }
235 if (nextNode) {
236 focusElement(nextNode, true);
237 }
238 return nextNode;
239 },
240 focusPrevious(opts: FocusManagerOptions = {}) {
241 let scope = scopeRef.current!;
242 let {from, tabbable, wrap, accept} = opts;

Callers

nothing calls this directly

Calls 8

getActiveElementFunction · 0.90
getOwnerDocumentFunction · 0.90
nodeContainsFunction · 0.90
getScopeRootFunction · 0.85
getFocusableTreeWalkerFunction · 0.85
isElementInScopeFunction · 0.85
focusElementFunction · 0.85
nextNodeMethod · 0.80

Tested by

no test coverage detected