From ac3c30480b906a9972e79cbf1ae7c6726596a4cf Mon Sep 17 00:00:00 2001 From: Diogo Bastos <50139916+DiogoABastos@users.noreply.github.com> Date: Mon, 17 Nov 2025 09:49:28 +0000 Subject: [PATCH] AAE-39949 Fix error while deleting empty row in repeatable section (#11346) --- .../widgets/core/form-field.model.spec.ts | 17 +++++++++++++++++ .../components/widgets/core/form-field.model.ts | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/lib/core/src/lib/form/components/widgets/core/form-field.model.spec.ts b/lib/core/src/lib/form/components/widgets/core/form-field.model.spec.ts index 3ae5fb4f31..2a77603a43 100644 --- a/lib/core/src/lib/form/components/widgets/core/form-field.model.spec.ts +++ b/lib/core/src/lib/form/components/widgets/core/form-field.model.spec.ts @@ -1467,6 +1467,23 @@ describe('FormFieldModel', () => { field.removeRow(0); expect(form.values[field.id]).toEqual(formValues.removeState); }); + + it('should call onFormFieldChanged if form values contains field id', () => { + spyOn(field.form, 'onFormFieldChanged').and.callThrough(); + + field.removeRow(1); + + expect(field.form.onFormFieldChanged).toHaveBeenCalled(); + }); + + it('should NOT call onFormFieldChanged if form values does NOT contain field id', () => { + spyOn(field.form, 'onFormFieldChanged').and.callThrough(); + + field.form.values = {}; + field.removeRow(1); + + expect(field.form.onFormFieldChanged).not.toHaveBeenCalled(); + }); }); describe('disabled state', () => { diff --git a/lib/core/src/lib/form/components/widgets/core/form-field.model.ts b/lib/core/src/lib/form/components/widgets/core/form-field.model.ts index a7c309c43e..f4618de844 100644 --- a/lib/core/src/lib/form/components/widgets/core/form-field.model.ts +++ b/lib/core/src/lib/form/components/widgets/core/form-field.model.ts @@ -487,6 +487,10 @@ export class FormFieldModel extends FormWidgetModel { this.rows.splice(index, 1); this.updateChildrenFieldsRowIndex(); + if (!this.form.values[this.id]) { + return; + } + this.form.values[this.id].splice(index, 1); this.form.onFormFieldChanged(this); }