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

Method _updateSelectedItemIndex

src/cdk/stepper/stepper.ts:549–573  ·  view source on GitHub ↗
(newIndex: number)

Source from the content-addressed store, hash-verified

547 }
548
549 private _updateSelectedItemIndex(newIndex: number): void {
550 const stepsArray = this.steps.toArray();
551 const selectedIndex = this._selectedIndex();
552
553 this.selectionChange.emit({
554 selectedIndex: newIndex,
555 previouslySelectedIndex: selectedIndex,
556 selectedStep: stepsArray[newIndex],
557 previouslySelectedStep: stepsArray[selectedIndex],
558 });
559
560 // If focus is inside the stepper, move it to the next header, otherwise it may become
561 // lost when the active step content is hidden. We can't be more granular with the check
562 // (e.g. checking whether focus is inside the active step), because we don't have a
563 // reference to the elements that are rendering out the content.
564 if (this._keyManager) {
565 this._containsFocus()
566 ? this._keyManager.setActiveItem(newIndex)
567 : this._keyManager.updateActiveItem(newIndex);
568 }
569
570 this._selectedIndex.set(newIndex);
571 this.selectedIndexChange.emit(newIndex);
572 this._stateChanged();
573 }
574
575 _onKeydown(event: KeyboardEvent) {
576 const hasModifier = hasModifierKey(event);

Callers 2

selectedIndexMethod · 0.95
resetMethod · 0.95

Calls 5

_containsFocusMethod · 0.95
_stateChangedMethod · 0.95
updateActiveItemMethod · 0.80
setMethod · 0.80
setActiveItemMethod · 0.45

Tested by

no test coverage detected