@gravitee/ui-particles-angular 7.17.1 → 7.17.2-fix-ps-4c96f71

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.
@@ -2974,11 +2974,6 @@ class GioFormJsonSchemaComponent {
2974
2974
  }
2975
2975
  }
2976
2976
  ngOnInit() {
2977
- // Invalid by default.
2978
- this.ngControl?.control?.addAsyncValidators(() => {
2979
- return this.isValid$.pipe(takeUntil(this.unsubscribe$), take(1), map(isValid => (isValid ? null : { invalid: true })));
2980
- });
2981
- this.ngControl?.control?.updateValueAndValidity({ emitEvent: false });
2982
2977
  // When the parent form is touched, mark all the sub formGroup as touched if not already touched
2983
2978
  const parentControl = this.ngControl?.control?.parent;
2984
2979
  parentControl?.statusChanges
@@ -2990,27 +2985,22 @@ class GioFormJsonSchemaComponent {
2990
2985
  this.formGroup.markAllAsTouched();
2991
2986
  this.stateChanges$.next();
2992
2987
  });
2993
- // Group all valueChanges events emit by formly in a single one
2994
- merge(this.formGroup.statusChanges, this.formGroup.valueChanges)
2995
- .pipe(takeUntil(this.unsubscribe$), debounceTime(100))
2996
- .subscribe(() => {
2997
- this.stateChanges$.next();
2988
+ // Add async validator to the parent
2989
+ this.ngControl?.control?.addAsyncValidators(() => {
2990
+ return this.isValid$.pipe(takeUntil(this.unsubscribe$), take(1), map(isValid => (isValid ? null : { invalid: true })));
2998
2991
  });
2999
- }
3000
- ngAfterViewInit() {
3001
2992
  // Subscribe to state changes to manage touches, status and value
3002
- this.stateChanges$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2993
+ this.stateChanges$
2994
+ .pipe(tap(() => {
3003
2995
  const { status, value, touched } = this.formGroup;
3004
2996
  if (this.isDisabled) {
3005
2997
  return;
3006
2998
  }
3007
2999
  if (status === 'VALID') {
3008
3000
  this.isValid$.next(true);
3009
- this.ngControl?.control?.setErrors(null);
3010
3001
  }
3011
3002
  if (status === 'INVALID') {
3012
3003
  this.isValid$.next(false);
3013
- this.ngControl?.control?.setErrors({ invalid: true });
3014
3004
  }
3015
3005
  if (touched && !this.touched) {
3016
3006
  this._onTouched();
@@ -3019,8 +3009,21 @@ class GioFormJsonSchemaComponent {
3019
3009
  if (this.touched) {
3020
3010
  this._onChange(value);
3021
3011
  }
3022
- this.ngControl?.control?.updateValueAndValidity({ emitEvent: false });
3012
+ }), delay(0),
3013
+ // Keep at the end
3014
+ takeUntil(this.unsubscribe$))
3015
+ .subscribe(() => {
3016
+ this.changeDetectorRef.markForCheck();
3023
3017
  this.changeDetectorRef.detectChanges();
3018
+ this.ngControl?.control?.updateValueAndValidity();
3019
+ });
3020
+ }
3021
+ ngAfterViewInit() {
3022
+ // Group all valueChanges events emit by formly in a single one
3023
+ merge(this.formGroup.statusChanges, this.formGroup.valueChanges)
3024
+ .pipe(takeUntil(this.unsubscribe$), debounceTime(100))
3025
+ .subscribe(() => {
3026
+ this.stateChanges$.next();
3024
3027
  });
3025
3028
  this.stateChanges$.next();
3026
3029
  }