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

Method _updateSelectedItemIndex

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

Source from the content-addressed store, hash-verified

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