Skip to content

bug(mat-tab): isActive is not set, and no events are emitted when active tab is replaced #24147

Closed
@james-schwartzkopf

Description

@james-schwartzkopf

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

I think this issue has always been present

Description

When the active tab is replaced (e.g. when *ngFor sees a new object in the active tabs position), no events are emitted, and the new tab does not have isActive set.

I can understand selectedIndexChange not firing since the selected index hasn't changed, but I'd argue there is a case for emitting selectedTabChange since the selected tab instance has changed.

Either way, isActive should be set on the new tabs instance.

Reproduction

Steps to reproduce:
https://stackblitz.com/edit/components-issue-fmcjbc?devtoolsheight=33&file=src%2Fapp%2Fexample-component.html

  1. Switch tabs, notice the events fire and tab.isActive updates
  2. Click the "Replace tab instance"
  3. Note that no events are emitted and tab.isActive is no longer true.

Expected Behavior

I would expect selectedTabChange to emit, and for tab.isActive to be true.

Actual Behavior

No events are emitted and tab.isActive is not false.

Environment

The stackblitz issue template appears to be 12.2, but I have duplicated this in 13. I was unable to fork the stackblitz from the tab examples in the docs.

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions