-
Notifications
You must be signed in to change notification settings - Fork 129
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
Why inputs are touched onload? #167
Comments
Yep, looks like a bug. I think it is some of the initialization done by Materialize that is causing it, which is difficult to change. I'll look more at it later. |
Other example, if you to init the field, touched is false. But is false always. If you erase all text touched be true. |
We are seeing the same issue. We are using ngMessages for our clientside validation messages. Looking through the code is appears to be related to this line::
in the below code: angular.module("ui.materialize.ngModel", [])
.directive("ngModel",["$timeout", function($timeout){
return {
restrict: 'A',
priority: -1, // lower priority than built-in ng-model so it runs first
link: function(scope, element, attr) {
scope.$watch(attr.ngModel,function(value, oldValue){
$timeout(function () {
// To stop an infinite feedback-loop with material multiple-select.
if (value instanceof Array && oldValue instanceof Array) {
if (value.length == oldValue.length) {
return;
}
}
if (value){
element.trigger("change");
} else if(element.attr('placeholder') === undefined) {
if(!element.is(":focus"))
element.trigger("blur"); //this line causes the issue
}
});
});
}
};
}]); If I remove that line all is good. Any ideas why that line is needed? |
The The fix might be to restrict when element.trigger("blur") is executed. |
Ah, this got me today. I may be wrong, but it's blur suppose to happen when user clicks on different element? As an opposite to focus. It messes up how validation works in angularjs. |
The inputs onload initial are touched set true.
Steps to reproduce
What exactly is supposed to happen
I've create a JSFiddle with angular only http://jsfiddle.net/carscx/mjud3r47/1/ and I've modified their JSFiddle http://jsfiddle.net/nb8116u4/2/ to see the differences
A link to a page clearly demonstrating the issue
http://jsfiddle.net/nb8116u4/2/
The text was updated successfully, but these errors were encountered: