ngOfficeUIFabric / ng-officeuifabric

Office UI Fabric (https://github.com/OfficeDev/office-ui-fabric) implementation for Angular
http://ngOfficeUiFabric.com
MIT License
321 stars 67 forks source link

datepicker set form (ngForm) $dirty=true on initial load #410

Closed patrick904 closed 7 years ago

patrick904 commented 8 years ago

When initialising my ngForm with data (async) the datepicker set the form $dirty flag to true. Without the datepicker the form stays $dirty=false, $valid=true etc. as expected.

This happends because after setting the ngModel value in the compile function the onSet trigger of the datepicker is fired and sets this initial value again to ngModel and so the form becomes dirty.

This could be solved by adding a third parameter to this.getPicker().set('select', value); on line 43: this.getPicker().set('select', value, { 'muted': true});. With this third paramter the triggers - onSet etc. - won't be fired off and thr form stays valid.

ghost commented 8 years ago

Related issue: https://github.com/ngOfficeUIFabric/ng-officeuifabric/issues/377

@patrick904 Could you please confirm whether your issue is a different one, or a duplicate?

patrick904 commented 8 years ago

It is related, but not a duplilcate. In #377(#361) $dirty ist NOT set to true. In this case $dirty is set to true when data ist loaded (initial load the form data). All my other controls (Input, select etc.) are not set to dirty but the datepicker is. So: no duplicate but a related issue.

jjczopek commented 7 years ago

@patrick904 : do you have a working example of the issue or a plunk like we have for other issues? That would be very helpful.