(opts: FocusManagerOptions = {})
| 237 | function createFocusManagerForScope(scopeRef: React.RefObject<Element[] | null>): FocusManager { |
| 238 | return { |
| 239 | focusNext(opts: FocusManagerOptions = {}) { |
| 240 | let scope = scopeRef.current!; |
| 241 | let {from, tabbable, wrap, accept} = opts; |
| 242 | let node = from || getActiveElement(getOwnerDocument(scope[0] ?? undefined))!; |
| 243 | let sentinel = scope[0].previousElementSibling!; |
| 244 | let scopeRoot = getScopeRoot(scope); |
| 245 | let walker = getFocusableTreeWalker(scopeRoot, {tabbable, accept}, scope); |
| 246 | walker.currentNode = isElementInScope(node, scope) ? node : sentinel; |
| 247 | let nextNode = walker.nextNode() as FocusableElement; |
| 248 | if (!nextNode && wrap) { |
| 249 | walker.currentNode = sentinel; |
| 250 | nextNode = walker.nextNode() as FocusableElement; |
| 251 | } |
| 252 | if (nextNode) { |
| 253 | focusElement(nextNode, true); |
| 254 | } |
| 255 | return nextNode; |
| 256 | }, |
| 257 | focusPrevious(opts: FocusManagerOptions = {}) { |
| 258 | let scope = scopeRef.current!; |
| 259 | let {from, tabbable, wrap, accept} = opts; |
nothing calls this directly
no test coverage detected