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