bietkul / react-reactive-form

Angular like reactive forms in React.
MIT License
309 stars 32 forks source link

dirty/pristine shouldn't be affected by onBlur if value didn't change #31

Closed dannyhuly closed 5 years ago

dannyhuly commented 5 years ago

Hi, I was following the Angular Template-driven validation to implement some kind of a Create New XXXX form.

In my implementation I noticed that the dirty/pristine were updating onBlur (click into the input and clicking outside the input) although no value was changed. This is a bit of an issue if you what to display errors only after a user changed a values.

The below implementations have the same logic:
Angular: https://stackblitz.com/edit/angular-t7dnq6-dfpyur?file=src%2Fapp%2Fname-editor%2Fname-editor.component.html React: https://codesandbox.io/s/64rplmk3pw

I would like to submit a PR with a fix but I need a bit of direction to how the onBlur effects an AbstractControl.

Thank, Daniel.

bietkul commented 5 years ago

Thanks for reporting the issue, it has been fixed in the latest verison.