Blazor - MudDialog will hide on rerendering caused by form data binding

Viewed 240

I have a table of data and there is a button to add row to this table. The button will show a dialog that contains a form so the user can fill it and then submit it.

I'm using MudBlazor and the inline dialog that is documented here

<MudButton OnClick="OpenDialog" >+</MudButton>
...

<MudDialog @bind-IsVisible="visible" Options="dialogOptions">
    ...

    <DialogContent>
        <EditForm Model="model" OnValidSubmit="Submit">
            <DataAnnotationsValidator />

            <MudTextField Label="Name" @bind-Value="model.Name" For="@(() => model.Name)" />
            ...

            <MudButton ButtonType="ButtonType.Submit">
                Submit
            </MudButton>
        </EditForm>
    </DialogContent>
</MudDialog>

@code {
    private bool visible;
    private void OpenDialog() => visible = true;

    //...
}

When I change the input and lose focus (meaning I go to the next input for example), it causes the UI to re-render (which is correct and expected), but then the visible variable becomes false and the dialog will hide (but the state is preserved). Is this a bug or am I missing something?

0 Answers
Related