mn-angular-lib 1.0.156 → 1.0.157
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.
|
@@ -8702,6 +8702,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
|
|
|
8702
8702
|
|
|
8703
8703
|
class MnFormBodyComponent {
|
|
8704
8704
|
fb = inject(FormBuilder);
|
|
8705
|
+
/**
|
|
8706
|
+
* Change detector used to announce state this component mutates outside an Angular
|
|
8707
|
+
* event handler — after an `await`, or from an RxJS subscription. Consuming apps run
|
|
8708
|
+
* zoneless, where such a write notifies nothing: the view is never marked dirty, so it
|
|
8709
|
+
* keeps rendering the stale value and `checkNoChanges` then reports it as NG0100
|
|
8710
|
+
* (e.g. the submit button staying disabled on "Submitting..." after a failed submit).
|
|
8711
|
+
* Every async mutation of {@link isSubmitting}, {@link fieldLoading}, {@link fieldOptions}
|
|
8712
|
+
* and {@link formErrors} must be followed by `markForCheck()`.
|
|
8713
|
+
*/
|
|
8714
|
+
cdr = inject(ChangeDetectorRef);
|
|
8705
8715
|
config;
|
|
8706
8716
|
modalRef;
|
|
8707
8717
|
hideFooter = false;
|
|
@@ -9132,6 +9142,7 @@ class MnFormBodyComponent {
|
|
|
9132
9142
|
}
|
|
9133
9143
|
async loadFieldOptions(key, dataSource, formValue) {
|
|
9134
9144
|
this.fieldLoading[key] = true;
|
|
9145
|
+
this.cdr.markForCheck();
|
|
9135
9146
|
try {
|
|
9136
9147
|
this.fieldOptions[key] = await dataSource.load(formValue);
|
|
9137
9148
|
}
|
|
@@ -9140,7 +9151,10 @@ class MnFormBodyComponent {
|
|
|
9140
9151
|
this.fieldOptions[key] = [];
|
|
9141
9152
|
}
|
|
9142
9153
|
finally {
|
|
9154
|
+
// Resolved after an `await`, so nothing has told Angular the spinner can go and the
|
|
9155
|
+
// options have arrived. Without this the field renders "Loading options..." forever.
|
|
9143
9156
|
this.fieldLoading[key] = false;
|
|
9157
|
+
this.cdr.markForCheck();
|
|
9144
9158
|
}
|
|
9145
9159
|
}
|
|
9146
9160
|
// =========================
|
|
@@ -9281,6 +9295,10 @@ class MnFormBodyComponent {
|
|
|
9281
9295
|
this.reloadDependentDataSources(formValue);
|
|
9282
9296
|
// Emit status change
|
|
9283
9297
|
this.formStatusChange.emit(this.form.status);
|
|
9298
|
+
// `valueChanges` can fire from outside an Angular event handler (a CVA writing on
|
|
9299
|
+
// init, or a caller patching the form), and the callbacks above rewrite visibility,
|
|
9300
|
+
// required-state and cross-field errors that the template reads.
|
|
9301
|
+
this.cdr.markForCheck();
|
|
9284
9302
|
});
|
|
9285
9303
|
}
|
|
9286
9304
|
previousFormValue = {};
|
|
@@ -9344,8 +9362,11 @@ class MnFormBodyComponent {
|
|
|
9344
9362
|
this.modalRef.close(formValue);
|
|
9345
9363
|
}
|
|
9346
9364
|
catch (error) {
|
|
9347
|
-
// Always allow retry on error, regardless of submit mode
|
|
9365
|
+
// Always allow retry on error, regardless of submit mode. This runs after an `await`,
|
|
9366
|
+
// so it must announce itself: otherwise the button stays disabled on "Submitting..."
|
|
9367
|
+
// and the user can never retry the action that just failed.
|
|
9348
9368
|
this.isSubmitting = false;
|
|
9369
|
+
this.cdr.markForCheck();
|
|
9349
9370
|
console.error('Form submission error:', error);
|
|
9350
9371
|
}
|
|
9351
9372
|
}
|