@fuentis/phoenix-ui 0.0.9-alpha.526 → 0.0.9-alpha.527

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.
@@ -3929,28 +3929,27 @@ class MetaFormAbstract {
3929
3929
  * - binds dependencies (safe rebind)
3930
3930
  * - recomputes validity
3931
3931
  */
3932
+ // MetaFormAbstract (samo bitne izmene – kompletno je kompatibilno sa tvojim kodom)
3932
3933
  syncForm() {
3933
3934
  const flatControls = this.flattenControls(this.metaFormControls);
3934
3935
  const values = this.metaFormValues ?? null;
3935
- // 1) Ensure form controls exist + validators are applied
3936
+ // 1) Ensure controls + apply validators
3936
3937
  this.ensureControls(flatControls);
3937
3938
  // 2) Patch initial values WITHOUT firing valueChanges
3938
3939
  if (values) {
3939
3940
  this.metaForm.patchValue(values, { emitEvent: false });
3940
3941
  }
3941
- // 3) Enable/disable entire form if requested
3942
+ // 3) Enable/disable entire form without emitting
3942
3943
  if (this.disableForm)
3943
3944
  this.metaForm.disable({ emitEvent: false });
3944
3945
  else
3945
3946
  this.metaForm.enable({ emitEvent: false });
3946
- // 4) Bind dependencies if needed (rebind when metadata changes)
3947
+ // 4) Bind dependencies (safe rebind)
3947
3948
  this.bindDependenciesIfNeeded(flatControls);
3948
- // 5) Notify that the form is ready
3949
+ // 5) Compute validity NOW (sync) but DO NOT emit (critical!)
3950
+ this.metaForm.updateValueAndValidity({ emitEvent: false });
3951
+ // 6) Notify that build is complete (signal to parent)
3949
3952
  this.metaService.setFormBuildCompletition(true);
3950
- // 6) Emit one stable status update AFTER the current CD cycle
3951
- queueMicrotask(() => {
3952
- this.metaForm.updateValueAndValidity({ emitEvent: true });
3953
- });
3954
3953
  }
3955
3954
  /**
3956
3955
  * Supports both:
@@ -4060,13 +4059,10 @@ class MetaFormAbstract {
4060
4059
  if (!hasServerUnique)
4061
4060
  return;
4062
4061
  const { uniqueEntry, unique, ...rest } = errors;
4063
- ctrl.setErrors(Object.keys(rest).length ? rest : null, {
4064
- emitEvent: false,
4065
- });
4066
- // Recompute the parent form validity so UI can enable Save immediately.
4067
- queueMicrotask(() => {
4068
- this.metaForm.updateValueAndValidity({ emitEvent: true });
4069
- });
4062
+ // Clear only server errors, keep other validators
4063
+ ctrl.setErrors(Object.keys(rest).length ? rest : null, { emitEvent: false });
4064
+ // IMPORTANT: after changing errors, re-run validity WITH EMIT
4065
+ this.metaForm.updateValueAndValidity({ emitEvent: true });
4070
4066
  });
4071
4067
  this.clearServerErrorSubs.set(key, sub);
4072
4068
  }