RadzenTemplateForm where TItem is a Record requires submit to be clicked twice when form is dirty #665

Closed
opened 2026-01-29 17:41:14 +00:00 by claunia · 1 comment
Owner

Originally created by @DanRogers99 on GitHub (Dec 7, 2022).

Describe the bug
When using a record type instead of a class in a Razen Template Form, when the form is dirty (Ie text added), and before the user clicks out of the input field, it is required to press submit twice.

To Reproduce
Steps to reproduce the behavior:

The example code below demonstrates the difference between using a record and a class.

<RadzenTemplateForm TItem="RecordModel" Data="@_recordModel" Submit="@OnRecordSubmit">
    <RadzenTextBox @bind-Value="@_recordModel.FirstName" />
    <RadzenButton ButtonType="ButtonType.Submit" Icon="save" Text="Submit"></RadzenButton>
</RadzenTemplateForm>

<RadzenTemplateForm TItem="ClassModel" Data="@_classModel" Submit="@OnClassSubmit">
    <RadzenTextBox @bind-Value="@_classModel.FirstName" />
    <RadzenButton ButtonType="ButtonType.Submit" Icon="save" Text="Submit"></RadzenButton>
</RadzenTemplateForm>

@code {
    record RecordModel
    {
        public string FirstName { get; set; }
    }

    class ClassModel
    {
        public string FirstName { get; set; }
    }
    
    private RecordModel _recordModel = new RecordModel();
    private ClassModel _classModel = new ClassModel();


    void OnRecordSubmit()
    {
        //Put breakpoint here
    }


    private void OnClassSubmit()
    {
        //Put breakpoint here
    }
}

Start typing in the text field and click submit before leaving the focus on the textbox.

If you lose focus before clicking submit it submits the first time.

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser Chrome
  • Version Version 108.0.5359.95
  • Radzen.Blazor: 4.4.3
Originally created by @DanRogers99 on GitHub (Dec 7, 2022). **Describe the bug** When using a record type instead of a class in a Razen Template Form, when the form is dirty (Ie text added), and before the user clicks out of the input field, it is required to press submit twice. **To Reproduce** Steps to reproduce the behavior: The example code below demonstrates the difference between using a record and a class. ``` <RadzenTemplateForm TItem="RecordModel" Data="@_recordModel" Submit="@OnRecordSubmit"> <RadzenTextBox @bind-Value="@_recordModel.FirstName" /> <RadzenButton ButtonType="ButtonType.Submit" Icon="save" Text="Submit"></RadzenButton> </RadzenTemplateForm> <RadzenTemplateForm TItem="ClassModel" Data="@_classModel" Submit="@OnClassSubmit"> <RadzenTextBox @bind-Value="@_classModel.FirstName" /> <RadzenButton ButtonType="ButtonType.Submit" Icon="save" Text="Submit"></RadzenButton> </RadzenTemplateForm> @code { record RecordModel { public string FirstName { get; set; } } class ClassModel { public string FirstName { get; set; } } private RecordModel _recordModel = new RecordModel(); private ClassModel _classModel = new ClassModel(); void OnRecordSubmit() { //Put breakpoint here } private void OnClassSubmit() { //Put breakpoint here } } ``` Start typing in the text field and click submit before leaving the focus on the textbox. If you lose focus before clicking submit it submits the first time. **Desktop (please complete the following information):** - OS: Windows 11 - Browser Chrome - Version Version 108.0.5359.95 - Radzen.Blazor: 4.4.3
Author
Owner

@akorchev commented on GitHub (Dec 7, 2022):

I pushed an attempted fix but I am not 100% sure it addresses the issue 1398e54896

Sometimes it worked without the fix, other it didn't. You can try pulling the master branch and testing in your application. The provided demo seems to work always with this fix applied.

@akorchev commented on GitHub (Dec 7, 2022): I pushed an attempted fix but I am not 100% sure it addresses the issue https://github.com/radzenhq/radzen-blazor/commit/1398e5489636247bb6db6891781581331ee2b8ac Sometimes it worked without the fix, other it didn't. You can try pulling the master branch and testing in your application. The provided demo seems to work always with this fix applied.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#665