Skip to content

Commit

Permalink
[HxInputDate] Changing value causes two calls of EditContext.OnFieldC…
Browse files Browse the repository at this point in the history
…hanged #787 (reprosteps)
  • Loading branch information
jirikanda committed Apr 12, 2024
1 parent 9f50a56 commit ab0429d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions BlazorAppTest/Pages/HxInputDate_Issue787_Test.razor
@@ -0,0 +1,37 @@
@page "/HxInputDate_Issue787_Test"
@using Havit;

<h1>HxInputDate[Range]</h1>

<EditForm EditContext="editContext">
<HxInputDate CssClass="col-3" Label="Date" @bind-Value="model.BirthDate" />
<HxInputDateRange CssClass="col-3" Label="DateRange" @bind-Value="model.DateRange" />
</EditForm>

<p>OnFieldChanged counter: @counter</p>

@code {

int counter;
private Person model;
private EditContext editContext;

protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
model = new Person();
editContext = new EditContext(model);
editContext.OnFieldChanged += HandleFieldChanged;
}

private void HandleFieldChanged(object sender, EventArgs eventArgs)
{
counter += 1;
}

public class Person
{
public DateTime BirthDate { get; set; }
public DateTimeRange DateRange { get; set; }
}
}

0 comments on commit ab0429d

Please sign in to comment.