@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.
- package/esm2020/src/app/core/form/form.utils.mjs +19 -4
- package/fesm2015/sumaris-net.ngx-components.mjs +18 -3
- package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
- package/fesm2020/sumaris-net.ngx-components.mjs +18 -3
- package/fesm2020/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
4634
|
-
if (
|
|
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
|
}
|