Skip to content

Mat-Stepper: Setting selected index to dynamically added step causes exception #17134

Open
@Antonvb

Description

@Antonvb

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/edit/angular-cdafd9?file=app%2Fstepper-overview-example.ts

Steps to reproduce:

  1. Create a mat-stepper component that renders mat-step elements from an array
  2. Pass in the selected index from the component (initially set to 0)
  3. Add a new element to the steps array for a dynamically added step and set the selected index to the new step index

Expected Behavior

Would expect to navigate to the new step component that was just added and for the stepper header to update

Actual Behavior

The new step gets added as expected, but the updating of the selected index leads to an exception Error: cdkStepper: Cannot assign out-of-bounds value to selectedIndex - although the assigned index matches the last element in the array used to render the steps

Environment

  • Angular: 8.2.6
  • CDK/Material: 8.1.4
  • Browser(s): Chrome 77
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/stepper

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions