(element: Element, scope: ScopeRef = null)
| 506 | } |
| 507 | |
| 508 | function isElementInChildScope(element: Element, scope: ScopeRef = null) { |
| 509 | // If the element is within a top layer element (e.g. toasts), always allow moving focus there. |
| 510 | if (element instanceof Element && element.closest('[data-react-aria-top-layer]')) { |
| 511 | return true; |
| 512 | } |
| 513 | |
| 514 | // node.contains in isElementInScope covers child scopes that are also DOM children, |
| 515 | // but does not cover child scopes in portals. |
| 516 | for (let {scopeRef: s} of focusScopeTree.traverse(focusScopeTree.getTreeNode(scope))) { |
| 517 | if (s && isElementInScope(element, s.current)) { |
| 518 | return true; |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | return false; |
| 523 | } |
| 524 | |
| 525 | /** @private */ |
| 526 | export function isElementInChildOfActiveScope(element: Element): boolean { |
no test coverage detected