Skip to content

Conversation

Maks3w
Copy link
Contributor

@Maks3w Maks3w commented Nov 12, 2014

Invalid element is not focused when validate a custom set of inputs and the last one is a valid input.

The issue is showErrors method reset errorList state after validate each input so the global state of the validator is not preserved.

Invalid element is not focused when validate a custom set of inputs and the last one is a valid input.
The issue is showErrors method reset errorList state after validate each input so the global state of the validator is not preserved
valid = true;
validator = $( this[ 0 ].form ).validate();
this.each( function() {
valid = validator.element( this ) && valid;
errorList = errorList.concat( validator.errorList );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this lists only be merged in case the input/element is not valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you've noticed that from a performance view. In this case is more faster to do a var reference assignment rather than:

  1. get the valid value
  2. then compare
  3. Optionally asign the var reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I prefer don't discuss how make this fragment better. I think is better fix the problem inside of showError method, but I don't have more time for spent on this (too much time I spent for find the scenario and the source problem)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, thanks.

@Maks3w
Copy link
Contributor Author

Maks3w commented Dec 2, 2014

@jzaefferer Ping!

Even if this is not be the best patch, at least fix the issue. This is the most important!

@jzaefferer
Copy link
Collaborator

I dug into this a bit, then landed it, after an update of the commit message. The showErrors method is problematic, but wasn't the problem here. The reset happens in reset(), called by prepareElement(), called by element(), called by valid(). The remaining issue is related to the remote validation method, and any other calls to showErrors with an argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants