ngx-eiffage-material 0.0.26 → 0.0.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.
@@ -800,13 +800,26 @@ class NgxPaginatedSelect {
800
800
  // effect
801
801
  controlEffect = effect(() => {
802
802
  const selectedItems = this._selectedItems();
803
+ const currentControlValue = this.control()?.value;
803
804
  if (this.multiple()) {
804
- this.control()?.setValue(selectedItems.map((item) => item[this.config().valueKey]));
805
- this.valueChange.emit(selectedItems);
805
+ const newValue = selectedItems.map((item) => item[this.config().valueKey]);
806
+ // Solo actualizar si el valor ha cambiado realmente
807
+ if (JSON.stringify(newValue) !== JSON.stringify(currentControlValue)) {
808
+ this.control()?.setValue(newValue, { emitEvent: false });
809
+ this.valueChange.emit(selectedItems);
810
+ }
806
811
  }
807
812
  else {
808
- this.control()?.setValue(selectedItems?.[0]?.[this.config().valueKey]);
809
- this.valueChange.emit(selectedItems?.[0]);
813
+ const newValue = selectedItems?.[0]?.[this.config().valueKey];
814
+ // Solo actualizar si el valor ha cambiado realmente
815
+ // Comparar con == para permitir comparación de number vs string
816
+ if (newValue != currentControlValue) {
817
+ // Solo establecer si hay un nuevo valor válido O si estamos limpiando
818
+ if (newValue !== undefined || selectedItems.length === 0) {
819
+ this.control()?.setValue(newValue, { emitEvent: false });
820
+ this.valueChange.emit(selectedItems?.[0]);
821
+ }
822
+ }
810
823
  }
811
824
  this._cdr.markForCheck();
812
825
  }, ...(ngDevMode ? [{ debugName: "controlEffect" }] : []));