in src/focus.service.ts [371:397]
private findNextFocusable(
direction: Direction,
root: HTMLElement,
refRect: ClientRect,
ignore: Set<HTMLElement>,
) {
const directive = this.selected ? this.registry.find(this.selected) : undefined;
let nextElem: HTMLElement | null = null;
if (directive) {
nextElem = this.focusByRegistry.findNextFocus(direction, directive);
}
if (!nextElem && this.enableRaycast) {
nextElem = this.findNextFocusByRaycast(direction, this.focusRoot, this.referenceRect);
}
if (!nextElem) {
const focusableElems = Array.from(root.querySelectorAll<HTMLElement>('[tabIndex]')).filter(
el => !ignore.has(el) && this.isFocusable(el),
);
const finder = new ElementFinder(direction, refRect, focusableElems, this.prevElement);
nextElem = finder.find();
}
return nextElem;
}