Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bug(MAT TAB): Mat-tab-group dont change properly in Lazy Loading Mode & selectedIndex #31703

Closed
Labels
needs triageThis issue needs to be triaged by the team
@danielschmitz

Description

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

material 19.1.5

Description

im using a Mat-Tab-Group with <ng-template matTabContent> to create a wizard (lazy), but the MatTab.selectedIndex don't work properly.

Example:
https://stackblitz.com/~/github.com/danielschmitz/tabs-as-wizard
demo: https://danielschmitz.github.io/tabs-as-wizard/
code: https://github.com/danielschmitz/tabs-as-wizard

Click "Next" Then "Back" ... dont works... but if click at radio.. the page back to 0 :-(

See

Image

My simple code:

a mat-tab with selectedIndex

<mat-tab-group [(selectedIndex)]="selectedIndex">
 <mat-tab label="Step 1">
 <ng-template matTabContent>
 <mat-card>
 <mat-card-title>Step 1 - Basic Info</mat-card-title>
 <mat-card-content>
 ..... form........
 </mat-card-content>
 <mat-card-actions>
 <button mat-stroked-button color="primary" (click)="prevTab()" [disabled]="isFirst">Back</button>
 <span class="spacer"></span>
 <button mat-raised-button color="primary" (click)="nextTab()" [disabled]="isLast">Next</button>
 </mat-card-actions>

The prevTab code:

nextTab(): void {
 if (!this.isLast) this.selectedIndex++;
 }
 prevTab(): void {
 if (!this.isFirst) this.selectedIndex--;
 }

Angular 19 & 20

Reproduction

StackBlitz link: https://stackblitz.com/~/github.com/danielschmitz/tabs-as-wizard
Steps to reproduce:

  1. Click Next Button
  2. In the Step 2, click Back (dont works)
  3. Click in the Radio Phone... page go back

Expected Behavior

  1. Click Next Button
  2. In the Step 2, click Back
  3. Page go back to Step 1

Actual Behavior

  1. Click Next Button
  2. In the Step 2, click Back (dont works)
  3. Click in the Radio Phone... page go back

Environment

  • Angular: 19.2.0
  • CDK/Material: 19.2.19
  • Browser(s): Chrome, Edge, Brave
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /