* Sets the tree to it's default initial state. * * Sets the active index of the tree to the first focusable selected tree item if one exists. * Otherwise, sets focus to the first focusable tree item.
()
| 400 | * Otherwise, sets focus to the first focusable tree item. |
| 401 | */ |
| 402 | setDefaultState() { |
| 403 | let firstItem: TreeItemPattern<V> | undefined; |
| 404 | |
| 405 | for (const item of this.inputs.items()) { |
| 406 | if (!item.visible()) continue; |
| 407 | if (!this.treeBehavior.isFocusable(item)) continue; |
| 408 | |
| 409 | if (firstItem === undefined) { |
| 410 | firstItem = item; |
| 411 | } |
| 412 | |
| 413 | if (item.selected()) { |
| 414 | this.activeItem.set(item); |
| 415 | return; |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | if (firstItem !== undefined) { |
| 420 | this.activeItem.set(firstItem); |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | /** Sets the default active state of the tree before receiving interaction for the first time. */ |
| 425 | setDefaultStateEffect(): void { |
no test coverage detected