MatBlazor
MatBlazor copied to clipboard
MatTabGroup: What is the current purpose of the ActiveIndex property? Can its functionality be extended?
Describe the feature request
MatTabGroup does not show the currently active tab after setting the tabIndex via ActiveIndex property in code behind, e.g. via <MatTabGroup @bind-ActiveIndex="@tabIndex">
or <MatTabGroup ActiveIndex="@tabIndex">
or <MatTabGroup ActiveIndex="2">
.
Expected behavior
I wish the setting ActiveIndex="@tabIndex" would have some functionality so that it switches to Tab 3 on the GUI automatically if I set <MatTabGroup ActiveIndex="2">
in the code behind.
Screenshots
Links to reproduce the issue Link: https://blazorfiddle.com/s/jo72rp45 or https://www.matblazor.com/Tab (3rd example 'Dynamically set tab index')
Remarks
It was already reported in https://github.com/SamProf/MatBlazor/issues/633 in the past. But I think it would be a great feature if the MatTabGroup would do the refresh on its own by default without I have to call StateHasChanged();
.
Update: Even if I call StateHasChanged();
, it does not work for me: The ActiveIndex property is simply ignored.
Update: I just noticed that all MatTab components have tabindex="0" when rendered in a for or foreach loop, the tabindex is not incremented. I would think now that someone had started to implement the ActiveIndex property, but that the implementation never was finished.
When rendering two MatTab's within a for loop inside of MatTabGroup, both MatTabs will have the same tabindex: