Skip to content
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

Error message issues - with fixes #25

Open
brianpkelley opened this issue Aug 10, 2016 · 0 comments
Open

Error message issues - with fixes #25

brianpkelley opened this issue Aug 10, 2016 · 0 comments

Comments

@brianpkelley
Copy link

Repeating this process on a required field was creating duplicated error messages:

  1. focus field
  2. fill field
  3. blur field
  4. focus field
  5. empty field
  6. blur field
    • Error message displayed.

Fixed by changing ng-if to ng-show on ng-messages dummy element created by sfMessagesNodeHandler.

I believe the behavior is documented here by the angular team. angular/angular.js#7549 (comment)


Error messages were not being removed on autocomplete fields, I'm not sure if this is better here or in the main angular-schema-form issue list, but I only noticed it on the md-autocomplete field.

Fixed by adding a method to the messages.js file for angular-schema-form and changing the ngModel watch to use it instead of update

    var updateAsync = function( checkForErrors ) {
        $timeout( function() { update(checkForErrors); } );
    };

...

    var once = scope.$watch('ngModel',function(ngModel) {
        if (ngModel) {
          // We also listen to changes of the model via parsers and formatters.
          // This is since both the error message can change and given a pristine
          // option to not show errors the ngModel.$error might not have changed
          // but we're not pristine any more so we should change!
          ngModel.$parsers.push(function(val) { updateAsync(true); return val; });
          ngModel.$formatters.push(function(val) { updateAsync(true); return val; });
          once();
        }
      });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants