@mediusinc/mng-commons 5.4.0-rc.1 → 5.4.0-rc.3

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.
@@ -2340,11 +2340,10 @@ class FormEditorComponent {
2340
2340
  const item = this.item();
2341
2341
  if (item !== this.initialItemInput) {
2342
2342
  // new item is different from the one the form was initialized with. Must trigger reset of form model.
2343
- this.resetFormModel(item);
2343
+ // should be executed in untracked mode, because it updates multiple components underneath
2344
+ untracked(() => this.resetFormModel(item));
2344
2345
  }
2345
- },
2346
- // resetModel uses signal like concept
2347
- { allowSignalWrites: true });
2346
+ });
2348
2347
  effect(() => {
2349
2348
  this._formlyOptions.formState.disabled =
2350
2349
  this.isFormDisabled() || this.autoSavePreviewDisabledForm() || this._formlyOptions.formState.descriptor?.disabled === true || this._formlyOptions.formState.details;
@@ -2471,6 +2470,7 @@ class FormEditorComponent {
2471
2470
  return formValue;
2472
2471
  }
2473
2472
  resetFormModel(item, opts) {
2473
+ // have to use formly's reset model, because _form.reset() does not reset the values correctly
2474
2474
  this._formlyOptions.resetModel?.(this.getFormModelFromItem(item));
2475
2475
  if (opts?.markAsPristine !== false) {
2476
2476
  // mark form as pristine, should be done in next event hook to allow formly to initialize first
@@ -2588,13 +2588,13 @@ class FormEditorComponent {
2588
2588
  const formModel = objectDeepCopy(item, { mapGettersToProperties: true }) ?? {};
2589
2589
  const descriptor = this.descriptor();
2590
2590
  descriptor.fields.forEach(field => {
2591
- if (field.getter && item) {
2591
+ if (field.getter && formModel) {
2592
2592
  const splitPath = field.property.split('.');
2593
2593
  let currentObject = formModel;
2594
2594
  for (let i = 0; i < splitPath.length; i++) {
2595
2595
  const currentSubPath = splitPath[i];
2596
2596
  if (i === splitPath.length - 1) {
2597
- currentObject[currentSubPath] = field.getter(item?.[field.property], item);
2597
+ currentObject[currentSubPath] = field.getter(formModel?.[field.property], formModel);
2598
2598
  }
2599
2599
  else {
2600
2600
  if (typeof currentObject[currentSubPath] !== 'object') {