@ngx-formly/core 5.10.26 → 5.10.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -803,13 +803,18 @@ FormlyFormBuilder.ctorParameters = () => [
803
803
  */
804
804
  function unregisterControl(field, emitEvent = false) {
805
805
  /** @type {?} */
806
- const form = (/** @type {?} */ (field.formControl.parent));
806
+ const control = field.formControl;
807
+ /** @type {?} */
808
+ const fieldIndex = control['_fields'] ? control['_fields'].indexOf(field) : -1;
809
+ if (fieldIndex !== -1) {
810
+ control['_fields'].splice(fieldIndex, 1);
811
+ }
812
+ /** @type {?} */
813
+ const form = (/** @type {?} */ (control.parent));
807
814
  if (!form) {
808
815
  return;
809
816
  }
810
817
  /** @type {?} */
811
- const control = field.formControl;
812
- /** @type {?} */
813
818
  const opts = { emitEvent };
814
819
  if (form instanceof FormArray) {
815
820
  /** @type {?} */
@@ -991,6 +996,8 @@ function updateControl(form, opts, action) {
991
996
  */
992
997
  function clearControl(form) {
993
998
  form['_fields'] && delete form['_fields'];
999
+ form.setValidators(null);
1000
+ form.setAsyncValidators(null);
994
1001
  if (form instanceof FormGroup || form instanceof FormArray) {
995
1002
  Object.keys(form.controls)
996
1003
  .forEach((/**
@@ -2600,6 +2607,19 @@ class FieldExpressionExtension {
2600
2607
  * @return {?}
2601
2608
  */
2602
2609
  toggleFormControl(field, hide, resetOnHide) {
2610
+ if (field.fieldGroup) {
2611
+ field.fieldGroup
2612
+ .filter((/**
2613
+ * @param {?} f
2614
+ * @return {?}
2615
+ */
2616
+ f => !f.hideExpression))
2617
+ .forEach((/**
2618
+ * @param {?} f
2619
+ * @return {?}
2620
+ */
2621
+ f => this.toggleFormControl(f, hide, resetOnHide)));
2622
+ }
2603
2623
  if (field.formControl && field.key) {
2604
2624
  defineHiddenProp(field, '_hide', !!(hide || field.hide));
2605
2625
  /** @type {?} */
@@ -2633,19 +2653,6 @@ class FieldExpressionExtension {
2633
2653
  }
2634
2654
  }
2635
2655
  }
2636
- if (field.fieldGroup) {
2637
- field.fieldGroup
2638
- .filter((/**
2639
- * @param {?} f
2640
- * @return {?}
2641
- */
2642
- f => !f.hideExpression))
2643
- .forEach((/**
2644
- * @param {?} f
2645
- * @return {?}
2646
- */
2647
- f => this.toggleFormControl(f, hide, resetOnHide)));
2648
- }
2649
2656
  if (field.options.fieldChanges) {
2650
2657
  field.options.fieldChanges.next((/** @type {?} */ ({ field, type: 'hidden', value: hide })));
2651
2658
  }