Hi, I just came accross a bug in the TelerikStepper.
I try to create a custom version that switches to a custom success icon after a step is completed.
It contains the following codesnippets:
<TelerikStepper Linear="true" ValueChanged="@HandleValueChanged">
<StepperSteps>
@for (int i = 0; i < IsValidArray.Length; i++)
{
<StepperStep Valid="@IsValidArray[i]"></StepperStep>
}
</StepperSteps>
</TelerikStepper>
@code {
bool?[] IsValidArray = [null, null, null, null];
public void HandleValueChanged(int index)
{
for (int i = 0; i < IsValidArray.Length; i++)
{
IsValidArray[i] = index > i ? true : null;
}
}
}
Forward it works like expected:
When moving backwards it behaves strange:
Except if you are debugging (Visual Studio debugger), then everything works as expected:
Same thing can be achived when not debugging but clicking on the step a second time
Hi Felix,
I apologize for my previous message not being accurate that the actual important part of the configuration is the Task.Delay. Let me provide a brief explanation below on why this is expected.
The example works correctly only when you add Task.Delay in the HandleValueChanged method because of the way Blazor handles state updates and component re-rendering.
Regards,
Hristian Stefanov
Progress Telerik
Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024
Hi Felix,
Here is an improved version of the configuration where I added the @key parameter. Using @key ensures that each StepperStep is accurately tracked and updated based on its unique index, which also guarantees correct DOM updates.
<TelerikStepper Linear="true" Value="@StepperValue" ValueChanged="@HandleValueChanged">
<StepperSteps>
@for (int i = 0; i < IsValidArray.Length; i++)
{
<StepperStep Valid="@IsValidArray[i]" @key="@i"></StepperStep>
}
</StepperSteps>
</TelerikStepper>
@code {
private int StepperValue { get; set; } = 0;
bool?[] IsValidArray = new bool?[] { null, null, null, null };
public async Task HandleValueChanged(int index)
{
StepperValue = index;
await Task.Delay(1);
for (int i = 0; i < IsValidArray.Length; i++)
{
IsValidArray[i] = index > i ? true : null;
}
}
}
The Stepper seems to work correctly. Thus, I'm marking this item as declined.
Regards,
Hristian Stefanov
Progress Telerik
Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024