Skip to content

[Tabs] Selection changes when tabs added/removed #7738

Closed
@thw0rted

Description

@thw0rted

Bug, feature request, or proposal:

Bug?

What is the expected behavior?

Adding or removing tabs shouldn't change which tab is selected

What is the current behavior?

Adding or removing tabs causes selection to change

What are the steps to reproduce?

Go to this plunker, and select one of the later tabs (5 or 6). Click the "Toggle" button at the top, and watch which tab is selected.

What is the use-case or motivation for changing an existing behavior?

The user didn't click on a different tab, so they don't expect the selected tab to change.


I believe the selected tab is based on an index / offset into the tab collection, so when *ngIf goes false, the collection shrinks and the same offset now points to a different tab. This might mean that you can't use *ngIf to hide tabs, which would mean that a) this needs to be documented, and b) an alternative property should be provided to signify "don't show this tab, but keep it in the collection so that its size doesn't change and mess up the selection offset". It would be nice if selection was instead based on a generated ID for each tab, but that might not be practical.

Metadata

Metadata

Labels

P2The issue is important to a large percentage of users, with a workaround

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions