Components: [Tabs] Allow users to assign IDs to tabs

Created on 18 Apr 2017  路  13Comments  路  Source: angular/components

Bug, feature request, or proposal:

proposal

What is the expected behavior?

Let the user define some "id" for the tab, to identify, outside the tab container, which tab is currently selected. Please note that this id may not necessarily be a substitute to the "selectedIndex" property, but some aditional content to identify which tab is currently selected.

What is the current behavior?

Today we can only know which tab is selected using the selectedIndex of md-tab-group, which is not really safe as the content of the tab may be changed and the index changes within it

What are the steps to reproduce?

Plunker

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

This is linked to #4135. The "workaround" that I found to use a "fixed" content relative to the current selected tab is to render the fixed element outside the tab-group and use the selectedIndex to show it.

Which versions of Angular, Material, OS, browsers are affected?

2.0.0-beta.3

P3 materiatabs feature needs discussion

Most helpful comment

This issue is already 3 years old. Common guys, just make it happen already...

All 13 comments

This would be great to have that because if you protect your tab with ngIf the index is not always the Same.

The id property should be provided in the current available events.

This would definitely be useful when programmatically setting the tab.

i also want set the tab programmatically +1

@finalxcode I am not saying it is a great solution but I have been programmatically selecting based on index.

I need this for e2e Tests

We need this because we have cases where some tabs are hidden with *ngIf, so the index is not reliable.

Very valid request! Its really needed!

any update guys?. I need this feature. it helps us to fix the e2e pipeline

Is there any progress on this feature request?

e2e testing is a nightmare because of this. I feel like I'm better off not using material components.

This issue is already 3 years old. Common guys, just make it happen already...

Would be nice indeed to be able to add some, for example, data-testid attributes to the DOM

Yeah, we need to be able to add some sort of attributes here, just ran into this now...

Was this page helpful?
0 / 5 - 0 ratings