-
Notifications
You must be signed in to change notification settings - Fork 27.6k
fix(form): make ngForm $pristine after nested control.$setPristine() (counter version) #13773
base: master
Are you sure you want to change the base?
Conversation
When calling $setPristine on the nested form or control, form becomes $pristine of all the nested controls are pristine Closes angular#13715
test/ng/directive/formSpec.js
Outdated
@@ -714,7 +714,8 @@ describe('form', function() { | |||
expect(form.$error.maxlength[0].$name).toBe('childform'); | |||
|
|||
inputController.$setPristine(); | |||
expect(form.$dirty).toBe(true); | |||
// this assertion prevents to propagate prestine to the parent form | |||
// expect(form.$dirty).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should change this to expect(form.$dirty).toBe(false);
and remove the subsequent call to form.$setPristine()
.
It generally LGTM (with a couple of nitpicks), BUT: We need to properly handle added/removed controls. |
70049ae
to
b77e14b
Compare
Now it uses internal counter. It's a bit complicated, because we have to divide |
I think it's best to have the two alternative approaches as two independent PRs (so we can review/update/decide upon separately). Thx @linoleum-js for working on this, btw 👍 |
Has this been split? |
When calling $setPristine on the nested form or control,
form becomes $pristine of all the nested controls are pristine
Closes #13715