-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HxInputDate] Not invoke field change #83
Comments
Hi @petrkasnal, |
@hakenr thank you for response. I understand, but when you insert correctly date and after write something incorrect like text the NotifyFieldChange isn't invoke. And i can't update my property FormValid. I update button state on OnFieldChange, beacuse i found many tutorials on this. Or should i update FormValidate property another way? I tried update my property in event OnValidationStateChanged with method Validate But then it's called over and over again. Can you tell me how to do another way please? When i try your HxInputNumber it works just like that. |
Aah, I see. (The HxInputNumber currently has a built-in workaround/hack which helps with the behavior, but we want this to be solved properly and thus we are trying to fix Blazor InputBase itself.) Anyway, the EditContext.OnFieldChanged is defined as
But the field value does not change when the input text is not valid. |
@jirikanda The bahavior of |
Thank you very much :) |
Not fixed/verified yet, just a comment for my colleague. :-D |
Implementation details:
The small difference can be hidden in this line in CurrentValue setter - it means when the value is fixed (modified) to the previosly valid value, CurrentValue does not notify the change. But when you implement the form well, I believe it works as expected. @page "/Issue83Test"
<h1>Issue 83</h1>
<EditForm EditContext="@numberEditContext">
<HxInputNumber @bind-Value="@numberModel.Value" Label="Number" />
<HxButton Text="Submit" Enabled="@(!numberEditContext.GetValidationMessages().Any())" Color="ThemeColor.Primary" />
</EditForm>
<EditForm EditContext="@dateEditContext">
<HxInputDate @bind-Value="@dateModel.Value" Label="Date" />
<HxButton Text="Submit" Enabled="@(!dateEditContext.GetValidationMessages().Any())" Color="ThemeColor.Primary" />
</EditForm>
@code
{
private EditContext numberEditContext;
private GenericModel<int> numberModel;
private EditContext dateEditContext;
private GenericModel<DateTime> dateModel;
private void HandleValidationStateChanged(object sender, ValidationStateChangedEventArgs args)
{
StateHasChanged();
}
protected override void OnInitialized()
{
base.OnInitialized();
numberModel = new GenericModel<int>();
numberEditContext = new EditContext(numberModel);
numberEditContext.OnValidationStateChanged += HandleValidationStateChanged;
dateModel = new GenericModel<DateTime>();
dateEditContext = new EditContext(numberModel);
dateEditContext.OnValidationStateChanged += HandleValidationStateChanged;
}
private class GenericModel<T>
{
public T Value { get; set; }
}
} |
…ůči NotifyFileChanged/ValidationStateChanged (github #83 [HxInputDate] Not invoke field change)
Hi, i maybe found little bug in component hxinputdate. But i'm not really sure if it is a bug. When is value changed component only notification validation state changed but don't notification field changed. Normally is invoke field change too. I use it for show/hide submit button. But maybe i haven't right and this is correct behaviour.
Thank you very much. :)

The text was updated successfully, but these errors were encountered: