Tab Selected is not correct

I'm trying to inspect the tab's Selected state and all of them are "false" no matter what.

Repro - https://github.com/timheuer/radzentabbug

Observe that the IsSelected internal is not in sync with Selected public property. Also can we ask that Index is made public readonly? That would be a helpful property to know.

Hi @timheuer,

This is by design. A blazor component should not keep its state in a [Parameter] property. We will expose other means to determine if a tab is selected e.g. the IsSelected and or Index properties. In the general case data-binding the SelectedIndex property of the RadzenTabs should work at the moment:

<RadzenTabs @bind-SelectedIndex=@selectedTabIndex>

In this case I’m curious about Selected not SelectedIndex. What is the purpose of Selected if it doesn’t represent the state of the tab. And now that you expose IsSelected and Selected what is the difference? The API shape with both of those public but not synced feels off.

I think the Blazor documentation article that I linked explains it very well. It contains an example which uses both Expanded property and private In short Blazor renders components upon change and set the parameter properties. If the component keeps the state it gets overwritten. This bit us hard in the early days. Hence there is Selected and IsSelected.

Basically you use either SelectedIndex or the Selected property of a tab (but not both) to set the selected tab (setting Selected overrides SelectedIndex). To get the selected index you either use @bind-SelectedIndex or check the IsSelected of the tab.

I saw the binding and that part makes sense. Just as someone approaching the API I would expect "IsSelected" and "Selected" to be both true in the event that it is the selected tab. :man_shrugging:

I would too and this is how it used to be originally :slight_smile: Then we discovered that when StateHasChanged is called all Selected properties got reset by Blazor (that's what made me report that issue which ended up by design and in the documentation).