Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrices doesn't work correctly if a column visibleIf returns false f… #7614

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/question_matrixdropdownbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
column.setVisibleChoicesInCell(newVisibleChoices);
if(!Helpers.isArraysEqual(curVisibleChoices, newVisibleChoices, true, false, false)) return true;
}
return curVis != column.isVisible;
return curVis !== column.isColumnVisible;
}
private updateNewVisibleChoices(q: Question, dest: Array<any>): void {
const choices = q.visibleChoices;
Expand Down
43 changes: 43 additions & 0 deletions testCafe/questions/matrixdynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,47 @@ frameworks.forEach((framework) => {
const surveyResult = await getSurveyResult();
await t.expect(surveyResult.matrix.length).eql(1);
});
});
const json4 = {
"textUpdateMode": "onTyping",
"focusFirstQuestionAutomatic": true,
"elements": [
{
"type": "matrixdynamic",
"name": "matrix",
"rowCount": 1,
"columns": [
{
"name": "col1",
"cellType": "text"
},
{
"name": "col2",
"cellType": "text"
},
{
"name": "col3",
"cellType": "text",
"visibleIf": "false"
}
]
}
]
};

frameworks.forEach((framework) => {
fixture`${framework} ${title}`.page`${url}${framework}`.beforeEach(
async (t) => {
await initSurvey(framework, json4);
}
);
test("column.visibleIf returns always false and rebuilding table", async (t) => {
await t.resizeWindow(1920, 1080);
await t.pressKey("a b c")
.pressKey("tab")
.pressKey("e d f")
.click(completeButton);
const surveyResult = await getSurveyResult();
await t.expect(surveyResult.matrix).eql([{ col1: "abc", col2: "edf" }]);
});
});
28 changes: 28 additions & 0 deletions tests/question_matrixdropdownbasetests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,4 +1073,32 @@ QUnit.test("checkIfValueInRowDuplicated has only one duplicated error", function
assert.equal(cellQuestion2.getType(), "tagbox", "type #2");
assert.equal(cellQuestion1.choices.length, 3, "choices #1");
assert.equal(cellQuestion2.choices.length, 4, "choices #2");
});
QUnit.test("Do not resetTable for always invisible column", function (assert) {
const survey = new SurveyModel({
"elements": [
{
"type": "matrixdynamic",
"name": "matrix",
"rowCount": 1,
"columns": [
{
"name": "col1",
"cellType": "text"
},
{
"name": "col2",
"cellType": "text",
"visibleIf": "false"
}
]
}
]
});
const matrix = <QuestionMatrixDropdownModelBase>survey.getQuestionByName("matrix");
const cellQuestion = matrix.visibleRows[0].cells[0].question;
const table = matrix.renderedTable;
table["$ref"] = "ref1";
cellQuestion.value = "test";
assert.equal(matrix.renderedTable["$ref"], "ref1", "Do not recreate the rendered table");
});
Loading