Skip to content

Commit

Permalink
fix: validation stops working when @bind-Value is set on the FluentWi…
Browse files Browse the repository at this point in the history
…zard component to an integer property on the page
  • Loading branch information
ErikJohnsonLRS committed Jul 11, 2024
1 parent 1ebdde8 commit 721edbb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Core/Components/Wizard/FluentWizard.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ protected virtual async Task OnNextHandlerAsync(MouseEventArgs e)
if (!isCanceled)
{
Value = targetIndex;
await ValueChanged.InvokeAsync(targetIndex);
StateHasChanged();
}
}
Expand All @@ -182,6 +183,7 @@ protected virtual async Task OnPreviousHandlerAsync(MouseEventArgs e)
if (!isCanceled)
{
Value = targetIndex;
await ValueChanged.InvokeAsync(targetIndex);
StateHasChanged();
}
}
Expand All @@ -190,9 +192,11 @@ protected virtual async Task OnPreviousHandlerAsync(MouseEventArgs e)
protected virtual async Task<FluentWizardStepChangeEventArgs> OnStepChangeHandlerAsync(int targetIndex, bool validateEditContexts)
{
var stepChangeArgs = new FluentWizardStepChangeEventArgs(targetIndex, _steps[targetIndex].Label);
var allEditContextsAreValid = false;

if (validateEditContexts)
{
var allEditContextsAreValid = _steps[Value].ValidateEditContexts();
allEditContextsAreValid = _steps[Value].ValidateEditContexts();
stepChangeArgs.IsCancelled = !allEditContextsAreValid;

if (!allEditContextsAreValid)
Expand All @@ -208,8 +212,6 @@ protected virtual async Task<FluentWizardStepChangeEventArgs> OnStepChangeHandle
await _steps[Value].InvokeOnSubmitForEditFormsAsync();
}

await ValueChanged.InvokeAsync(targetIndex);

return await OnStepChangeHandlerAsync(stepChangeArgs);
}

Expand Down Expand Up @@ -256,6 +258,7 @@ internal async Task GoToStepAsync(int targetIndex, bool validateEditContexts)
if (!isCanceled)
{
Value = targetIndex;
await ValueChanged.InvokeAsync(targetIndex);
StateHasChanged();
}
}
Expand Down

0 comments on commit 721edbb

Please sign in to comment.