@gravitee/ui-particles-angular 16.4.1 → 16.4.2

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.
@@ -3275,6 +3275,9 @@ class GioFormJsonSchemaComponent {
3275
3275
  this.touched = false;
3276
3276
  this.isValid$ = new ReplaySubject(1); // Wait JsonSchema to be loaded to check if it's valid
3277
3277
  this.stateChanges$ = new Subject();
3278
+ this.isWritingValue = false;
3279
+ this.isStable = false;
3280
+ this.isUpdatingParent = false;
3278
3281
  if (ngControl) {
3279
3282
  // Setting the value accessor directly (instead of using
3280
3283
  // the providers `NG_VALUE_ACCESSOR`) to avoid running into a circular import.
@@ -3321,9 +3324,9 @@ class GioFormJsonSchemaComponent {
3321
3324
  // Sync control value with default value (without emit event) as long as the component is not ready
3322
3325
  // When formly is initialised, it emits several values as it builds up step by step.
3323
3326
  this.formGroup.valueChanges
3324
- .pipe(distinctUntilChanged(isEqual), tap(value => {
3325
- this.ngControl?.control?.reset(value, { emitEvent: false });
3326
- }), takeUntil(this.ready), takeUntil(this.unsubscribe$))
3327
+ .pipe(distinctUntilChanged(isEqual), filter(() => !this.isWritingValue && this.isStable), tap(value => {
3328
+ this.syncValueToParent(value);
3329
+ }), takeUntil(this.unsubscribe$))
3327
3330
  .subscribe();
3328
3331
  // Avoid ExpressionChangedAfterItHasBeenCheckedError on project
3329
3332
  this.changeDetectorRef.markForCheck();
@@ -3381,7 +3384,22 @@ class GioFormJsonSchemaComponent {
3381
3384
  }
3382
3385
  // From ControlValueAccessor
3383
3386
  writeValue(value) {
3387
+ if (this.isUpdatingParent)
3388
+ return;
3389
+ this.isWritingValue = true;
3390
+ this.isStable = false;
3384
3391
  this.model = cloneDeep(value) ?? {};
3392
+ setTimeout(() => {
3393
+ this.isWritingValue = false;
3394
+ this.isStable = true;
3395
+ this.syncValueToParent(this.formGroup.value);
3396
+ this.changeDetectorRef.markForCheck();
3397
+ }, 0);
3398
+ }
3399
+ syncValueToParent(value) {
3400
+ this.isUpdatingParent = true;
3401
+ this.ngControl?.control?.setValue(value, { emitEvent: false });
3402
+ this.isUpdatingParent = false;
3385
3403
  }
3386
3404
  // From ControlValueAccessor
3387
3405
  registerOnChange(fn) {