Skip to content

Commit

Permalink
The Cannot read properties of null (reading 'forEach') exception is t…
Browse files Browse the repository at this point in the history
…hrown on an attempt to run a survey fix #7341 (#7342)
  • Loading branch information
andrewtelnov committed Nov 14, 2023
1 parent e16688e commit df52ca7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/question_matrixdropdownbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,7 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
this.collectNestedQuestonsInRows(this.visibleRows, questions, visibleOnly);
}
protected collectNestedQuestonsInRows(rows: Array<MatrixDropdownRowModelBase>, questions: Question[], visibleOnly: boolean): void {
if(!Array.isArray(rows)) return;
rows.forEach(row => {
row.questions.forEach(q => q.collectNestedQuestions(questions, visibleOnly));
});
Expand Down
23 changes: 23 additions & 0 deletions tests/question_matrixdropdownbasetests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -943,4 +943,27 @@ QUnit.test("checkIfValueInRowDuplicated has only one duplicated error", function
matrix.checkIfValueInRowDuplicated(row, q);
assert.equal(q.errors.length, 1, "One error only");
assert.equal(q.errors[0].getErrorType(), "keyduplicationerror", "Correct error is added");
});
QUnit.test("checkIfValueInRowDuplicated has only one duplicated error", function (assert) {
const survey = new SurveyModel({
"elements": [
{
"type": "matrixdynamic",
"name": "matrix",
"state": "collapsed",
"columns": [

{
"name": "col1",
"cellType": "dropdown",
"choices": ["a", "b"],
"showOtherItem": true,
"storeOthersAsComment": true
}
]
}
]
});
const matrix = <QuestionMatrixDropdownModelBase>survey.getQuestionByName("matrix");
assert.equal(matrix.columns.length, 1, "There is one column, it is loaded correctly");
});

0 comments on commit df52ca7

Please sign in to comment.