-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngModelController): always use last commited view value in validators #10299
Conversation
CLAs look good, thanks! |
@shahata Could you take a look at this? |
c541938
to
ac4e97b
Compare
@Narretz I'm not sure about this. Validators get both Also, I'm not sure I understand why a parser would call |
One problem is in this issue: #10126 The minlength validator will validate with a viewValue that is out of date, because parser -> (setViewValue -> parser -> validate) -> validate and because $$parseAndValidate caches the $$lastCommittedViewValue. Setting $viewValue directly does not fix this. |
Okay, I get it now, but let's say I have a parser that just removes the last I think that simply passing |
You are absolutely right, this breaks validation if a parser only truncates the model value. I even had the last committed view value solution, but wanted to skip the extra validation. I'll fix this up. |
b7eef7d
to
5542010
Compare
…dation This fixes issues where a parser calls $setViewValue. This is a common strategy for manipulating the $viewValue while the user is entering data into an input field. When the $viewValue was changed inside the parser, the new viewValue would be committed, parsed and used for validation. The original parser however would run after that and pass the original (outdated) viewValue on to the validators, which could cause false positives, e.g. for minlength. Fixes angular#10126 Fixes angular#10299
I updated the PR with your suggestion |
LGTM |
…dation This fixes issues where a parser calls $setViewValue. This is a common strategy for manipulating the $viewValue while the user is entering data into an input field. When the $viewValue was changed inside the parser, the new viewValue would be committed, parsed and used for validation. The original parser however would run after that and pass the original (outdated) viewValue on to the validators, which could cause false positives, e.g. for minlength. Fixes angular#10126 Fixes angular#10299
5542010
to
c4ff166
Compare
...ed
This fixes issues where a parser calls $setViewValue. This is a common
strategy for manipulating the $viewValue while the user is entering
data into an input field.
When the $viewValue was changed inside the parser, the new viewValue
would be committed and used for validation. The original parser
however would run last and pass the original (outdated) viewValue on
to the validators, which could cause false positives, e.g. for
minlength.
This is a regression since 1.3.0-rc.1, caused by 6046e14#diff-c244afd8def7f268b16ee91a0341c4b2L2055