* Gets the Field directive binding that should be focused when the developer calls * `focusBoundControl` on this node. * * This will prioritize focusable bindings to this node, and if multiple exist, it will return * the first one in the DOM. If no focusable bindings exist on this node,
()
| 117 | * first focusable binding in the DOM for any descendant node of this one. |
| 118 | */ |
| 119 | private getBindingForFocus(): |
| 120 | | (FormField<unknown> & {focus: (options?: FocusOptions) => void}) |
| 121 | | undefined { |
| 122 | // First try to focus one of our own bindings. |
| 123 | const own = this.formFieldBindings() |
| 124 | .filter( |
| 125 | (b): b is FormField<unknown> & {focus: (options?: FocusOptions) => void} => |
| 126 | b.focus !== undefined, |
| 127 | ) |
| 128 | .reduce( |
| 129 | firstInDom<FormField<unknown> & {focus: (options?: FocusOptions) => void}>, |
| 130 | undefined, |
| 131 | ); |
| 132 | if (own) return own; |
| 133 | // Fallback to focusing the bound control for one of our children. |
| 134 | return this.structure |
| 135 | .children() |
| 136 | .map((child) => child.getBindingForFocus()) |
| 137 | .reduce(firstInDom, undefined); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * The `AbortController` for the currently debounced sync, or `undefined` if there is none. |
no test coverage detected