-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HxInputDate] Changing value causes two calls of EditContext.OnFieldC…
…hanged #787 (reprosteps)
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } | ||
} | ||
} |