Welcome to the Blazor feedback portal. We’re happy you’re here! If you have feedback on how to improve the Blazor, we’d love to hear it!

  • Check out the features or bugs others have reported and vote on your favorites. Feedback will be prioritized based on popularity.
  • If you have feedback that’s not listed yet, submit your own.

Thanks for joining our community and helping improve Syncfusion products!

1
Vote

CheckBox controls become in infinite loop when you raise a StateHasChanged inside a OnFieldChanged.


To reproduce it:


Option 1: Run zipped attached file and go Counter.

Option 2: Just copy this MS sample

https://docs.microsoft.com/en-us/aspnet/core/blazor/forms-validation?view=aspnetcore-3.1

an include a checkbox inside. Like:


@implements IDisposable
@page "/counter"
@using Syncfusion.Blazor.Buttons

<EditForm EditContext="@editContext">
    <DataAnnotationsValidator />
    <ValidationSummary />

    <SfCheckBox Label="Default" @bind-Checked="starship.IsChecked" />

</EditForm>

@code {

    // https://docs.microsoft.com/en-us/aspnet/core/blazor/forms-validation?view=aspnetcore-3.1

    public class Starship
    {
        public bool IsChecked {getset;}
    }

    private Starship starship = new Starship();
    private bool formInvalid = true;
    private EditContext editContext;

    protected override void OnInitialized()
    {
        editContext = new EditContext(starship);
        editContext.OnFieldChanged += HandleFieldChanged;
    }

    private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
    {
        System.Console.WriteLine"***" ); 
        formInvalid = !editContext.Validate();
        StateHasChanged();
    }

    public void Dispose()
    {
        editContext.OnFieldChanged -= HandleFieldChanged;
    }
    
}