@sumaris-net/ngx-components 2.1.6 → 2.2.0

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.
@@ -4624,14 +4624,29 @@ class AppFormArray extends UntypedFormArray {
4624
4624
  initArrayControlsFromValues(this, this.createControl, values, options);
4625
4625
  }
4626
4626
  else {
4627
- this.resize(values?.length || 0);
4627
+ this.resize(values?.length || 0, { emitEvent: false });
4628
4628
  super.patchValue(values, options);
4629
4629
  }
4630
4630
  }
4631
4631
  resize(length, options) {
4632
+ if (this.length === length)
4633
+ return; // Nothing to do
4632
4634
  const enabled = this.enabled; // Save enabled here, because update can occur from resizeArray()
4633
- const changes = resizeArray(this, this.createControl, length, options);
4634
- if (changes) {
4635
+ // Increase size
4636
+ if (this.length < length) {
4637
+ while (this.length < length) {
4638
+ this.push(this.createControl(), { emitEvent: false /*will be done just after, if changes*/ });
4639
+ }
4640
+ }
4641
+ // Or reduce
4642
+ else {
4643
+ while (this.length > length) {
4644
+ this.removeAt(this.length - 1, { emitEvent: false /*will be done just after, if changes*/ });
4645
+ }
4646
+ }
4647
+ // Restore initial status
4648
+ // This is a workaround, because push and removeAt can have changed the array status
4649
+ if (this.enabled !== enabled) {
4635
4650
  if (enabled) {
4636
4651
  this.enable(options);
4637
4652
  }