-
Notifications
You must be signed in to change notification settings - Fork 420
fix: Initial Value not respected in [Wizard] #3759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can reproduce this as well.
Note after the component has been initiliazed this works just fine when the bound value has been changed from outside the component. It's only the initial value which will be ignored. |
@MarvinKlein1508 any idea how to fix it (asking because you've already investigated)? If so, can you create a PR in the next few hours? If yes we can take this in for 4.11.9. Otherwise it will go into next next release |
The main issue is that the I’m actually not sure how this could be fixed in a way that ensures subcomponents are initialized before the parent component finishes initializing. I’m not even sure that it’s possible. I did some testing, and the only workaround I found is to ignore steps.Count altogether and assume that if So, if I change
to: /// <summary>
/// Gets or sets the step index of the current step.
/// This value is bindable.
/// </summary>
[Parameter]
public int Value
{
get
{
return _value;
}
set
{
if (_steps.Count is 0)
{
_value = value;
}
else if (value < 0 || _steps.Count <= 0)
{
_value = 0;
}
else if (value > _steps.Count - 1)
{
_value = _steps.Count - 1;
}
else
{
_value = value;
}
_maxStepVisited = Math.Max(_value, _maxStepVisited);
SetCurrentStatusToStep(_value);
}
} And also update
to: private bool DisplayPreviousButton => Value > 0 && _steps.Count > 0 && _steps[..Value].Any(i => !i.Disabled);
private bool DisplayNextButton => Value < _steps.Count - 1 && _steps.Count > 0 && _steps[(Value + 1)..].Any(i => !i.Disabled); ...then the issue is resolved. However, I’m not sure if this is the most robust or appropriate solution. Let me know what you two think. |
Without looking at the code in depth, I can say that having a parameter that isn't a simple get;set property is not a recommended way in Blazor (I saw it is already like that in the existing code, so we need to change that later on) But going on what you said, we'll fix it for an upcoming release. So no rush! |
Yes. I would also do this in an upcoming release. If you want to change the behaviour of the property this might require a significant amount of work. But this is definately a bug within the components :) |
What about do it in a similar way to how the grid does it's start/end column calls. That will give a clear event when to set actual step and do the limit. fluentui-blazor/src/Core/Components/DataGrid/FluentDataGrid.razor Lines 15 to 18 in 3549c0b
|
That could work but I think it is a bit of overkill for the Wizard. In a DataGrid there are frequent changes to columns. In a Wizard though, the number of steps will almost never need to change. |
True, but it would also eliminate those corner cases where the steps sometimes don't restart the numbering when the page gets re-rendered. I haven't made a bug for it since it happens quite rare. |
ok, Defer also works as a workaround... <FluentWizard @bind-Value="_currentStep"
...
</FluentWizardStep>
<Microsoft.FluentUI.AspNetCore.Components.DataGrid.Infrastructure.Defer>
@{
if (_currentStep != _startStep)
{
_currentStep = _startStep;
StateHasChanged();
}
}
</Microsoft.FluentUI.AspNetCore.Components.DataGrid.Infrastructure.Defer>
</Steps> |
As you say, You could use the FluentWizard MyWizard = default!;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await MyWizard.GoToStepAsync(1);
}
} |
Closing this as there is a workaound now |
🐛 Bug Report
The
Value
onFluentWizard
evaluates its guard check BEFORE steps are actually added. It therefore always fails the_steps.Count <= 0
check and you always start on step 0.💻 Repro or Code Sample
<FluentWizard StepSequence="Any" @bind-Value="Step" ..
🤔 Expected Behavior
Wizard respects the initial step
😯 Current Behavior
Initial step value is ignored
🌍 Your Environment
4.11.8
The text was updated successfully, but these errors were encountered: