MCPcopy Create free account
hub / github.com/angular/components / setDefaultState

Method setDefaultState

src/aria/private/tree/tree.ts:402–422  ·  view source on GitHub ↗

* 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.

()

Source from the content-addressed store, hash-verified

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 {

Callers 2

setDefaultStateEffectMethod · 0.95
tree.spec.tsFile · 0.45

Calls 4

visibleMethod · 0.80
setMethod · 0.80
isFocusableMethod · 0.45
selectedMethod · 0.45

Tested by

no test coverage detected