jrief / django-angular

Let AngularJS play well with Django
http://django-angular.awesto.com/
MIT License
1.23k stars 294 forks source link

Use $touched together with $dirty #314

Closed jrief closed 6 years ago

jrief commented 6 years ago

This fixes #248 and supersedes #260.

Until version 1.1.3, whenever a client typed into a field which at the time did not validate, an error popped up immediately.

Example: In a form, we define say, a CharField(min_length=3). If that field is rendered by django-angular, it is marked as invalid as soon as the client types the first character. The error message disappears as soon as he entered the third character. This from a usability point of view is not ideal.

Instead with this change, the error message only appears when the field is invalid and loses focus. From my point of view this gives a much nicer user experience.

@adrienbrunet @jkosir what do you think of it? Please review this PR.

@itsjeyd @omarkhan can I extend this to fulfill what you wanted to achieve in #260 ?

adrienbrunet commented 6 years ago

The code changes are ok for me. I think this will indeed increase the user experience. I was quite annoyed by emailField and URLField behaviours.

Does it fix completely the behaviour with server side validation (see screenshot in #260) ?

Just a reminder how to delay validation or at least model updates until this fix : ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }"

Keep on the good work jrief, as always !

jrief commented 6 years ago

@adrienbrunet actually, I never was able to reproduce the screenshots as shown in #260. Maybe the CSS for ng-hide and ng-cloak were missing. Anyway, when I retested that PR I had this annotation, which never has been fixed.