diff --git a/src/question_custom.ts b/src/question_custom.ts index d887db0354..4e2156a269 100644 --- a/src/question_custom.ts +++ b/src/question_custom.ts @@ -1330,7 +1330,7 @@ export class QuestionCompositeModel extends QuestionCustomModelBase { const key = questions[i].getValueName(); const val = !!newValue ? newValue[key] : undefined; const q = questions[i]; - if(!this.isTwoValueEquals(q.value, val)) { + if(!this.isTwoValueEquals(q.value, val) && (val !== undefined || !q.isEmpty())) { q.value = val; } } diff --git a/tests/question_customtests.ts b/tests/question_customtests.ts index 50a3e8a8b7..94ebfefd95 100644 --- a/tests/question_customtests.ts +++ b/tests/question_customtests.ts @@ -3270,3 +3270,56 @@ QUnit.test("single component: inheritBaseProps - do not duplicate description pr assert.equal(descriptionCounter, 1, "We have one description property"); ComponentCollection.Instance.clear(); }); +QUnit.test("composite component: do not reset dynamic panels/dynamic rows, Bug#8612", function (assert) { + ComponentCollection.Instance.add({ + name: "customquestion", + elementsJSON: [ + { + type: "text", + name: "qText", + }, + { + "type": "paneldynamic", + "name": "panel", + "templateElements": [ + { + "type": "text", + "name": "question2" + } + ] + }, + { + "type": "matrixdynamic", + "name": "matrix", + "rowCount": 0, + "columns": [ + { + "cellType": "text", + "name": "col1" + } + ] + } + ] + }); + + const survey = new SurveyModel({ + elements: [ + { type: "customquestion", name: "q1" } + ] + }); + const q1 = survey.getQuestionByName("q1"); + const panel = q1.contentPanel.getQuestionByName("panel"); + const matrix = q1.contentPanel.getQuestionByName("matrix"); + const text = q1.contentPanel.getQuestionByName("qText"); + panel.addPanel(); + panel.addPanel(); + panel.addPanel(); + matrix.addRow(); + matrix.addRow(); + matrix.addRow(); + text.value = "abc"; + assert.equal(matrix.rowCount, 3, "There are 3 rows"); + assert.equal(panel.panelCount, 3, "There are 3 panels"); + + ComponentCollection.Instance.clear(); +});