angular-input-modified icon indicating copy to clipboard operation
angular-input-modified copied to clipboard

Modified state gets screwed when a subform is toggled

Open sakovias opened this issue 6 years ago • 1 comments

Hi @slavafomin, that's a great library, really liking it.

Here's an issue I came across when working with "nested" forms. I've checked that it occurs on versions 2.3.2 and 2.4.2 (possibly others). I have a form with a nested ng-form, the former gets toggled with ng-if. It looks like I can trick it into a "modified" state.

Here's the Plunker: https://plnkr.co/edit/YuYuG6M3SGWYiFE3jBKa?p=preview.

  • Start with a form with selected checkbox "B":

modified_1

  • Select option "foo" in the sub-form. The form is modified as expected:

modified_2

  • Unselect checkbox "B". The form is still modified:

modified_3

  • Select option "B" again. The form values are now different from the starting ones, but it's no longer marked as modified:

modified_4

Please let me know if there's a workaround and/or fix. Appreciate your help!

sakovias avatar Sep 22 '17 20:09 sakovias

There's a workaround to reset the subform to a "default" state. In the case of the above example, we can clear the subform when the box B is unchecked. We're going loose the state of the subform, but the modified flag will stay correct.

https://plnkr.co/edit/UiV4iJGLLr611gweWxHj?p=preview

sakovias avatar Sep 25 '17 15:09 sakovias