diff --git a/packages/survey-core/src/survey.ts b/packages/survey-core/src/survey.ts index a1f464922d..f25ea43edd 100644 --- a/packages/survey-core/src/survey.ts +++ b/packages/survey-core/src/survey.ts @@ -5913,11 +5913,9 @@ export class SurveyModel extends SurveyElementCore var question = questions[i]; this.checkQuestionErrorOnValueChanged(question); question.onSurveyValueChanged(newValue); - this.fireOnValueChanged(valueName, newValue, question); } - } else { - this.fireOnValueChanged(valueName, newValue, null); } + this.fireOnValueChanged(valueName, newValue, !!questionName ? this.getQuestionByName(questionName) : undefined); if (this.isDisposed) return; this.checkElementsBindings(valueName, newValue); this.notifyElementsOnAnyValueOrVariableChanged(valueName, questionName); diff --git a/packages/survey-core/tests/question_paneldynamic_tests.ts b/packages/survey-core/tests/question_paneldynamic_tests.ts index 7587a5f3d2..166f42bbdf 100644 --- a/packages/survey-core/tests/question_paneldynamic_tests.ts +++ b/packages/survey-core/tests/question_paneldynamic_tests.ts @@ -1612,6 +1612,61 @@ QUnit.test( ); } ); +QUnit.test("PanelDynamic vs MatrixDynamic onValueChanged, bug#9130", function(assert) { + const json = { + elements: [ + { + type: "matrixdynamic", + rowCount: 1, + name: "employer_names", + valueName: "employers", + columns: [ + { + name: "name", + isRequired: true, + cellType: "text", + }, + ], + }, + { + type: "paneldynamic", + renderMode: "list", + allowAddPanel: false, + allowRemovePanel: false, + name: "arrray_employer_info", + valueName: "employers", + templateTitle: "{panel.name}", + templateElements: [ + { + type: "text", + name: "address", + }, + { + type: "text", + name: "abn", + }, + { + type: "text", + name: "name", + } + ], + }, + ], + }; + const survey = new SurveyModel(json); + const logs = new Array(); + survey.onValueChanged.add((sender, options) => { + logs.push({ name: options.name, questionName: options.question.name }); + }); + const matrix = (survey.getQuestionByName("employer_names")); + const panel = (survey.getQuestionByName("arrray_employer_info")); + matrix.visibleRows[0].getQuestionByName("name").value = "def"; + panel.panels[0].getQuestionByName("name").value = "abc"; + assert.deepEqual(logs, [ + { name: "employers", questionName: "employer_names" }, + { name: "employers", questionName: "arrray_employer_info" } + ], "check logs, #1"); +}); function updateObjsQuestions(objs: Array): void { for (var i = 0; i < objs.length; i++) {