angular / angular/components

bug(mat-tab): tab group dynamic does not allow to select first tab if newly created

Open
#24,445 4 comments 0 reactions 0 assignees View on GitHub
area: material/tabs P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

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

_No response_

### Description

When i add a new tab dynamically from a button, if i choose to set the new tab as first item in the tab list and want it to select this tab, it does nothing.
I have to first select a new tab and then repeat it to make it works.

### Reproduction

https://stackblitz.com/edit/angular-qhbfy8?file=app/tab-group-dynamic-example.ts
Steps to reproduce:
1. Select checkbox : "Select tab after adding"
2. Click btn "Add new tab"

### Expected Behavior

It should select first tab

### Actual Behavior

it does not change the current tab

### Environment

- Angular: 13
- CDK/Material: 13
- Browser(s): Chrome

Contributor guide

Open the contributing guide

Research direction

Reproduce the problem using the linked StackBlitz, starting with app/tab-group-dynamic-example.ts and the steps for inserting a tab at the beginning. Trace how the dynamic mat-tab group handles selecting the newly inserted first tab. Done means selecting the checkbox and clicking “Add new tab” selects the first tab immediately.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.