Skip to content

Commit

Permalink
Multi-Select Matrix Column - The showOtherItem and showNoneItem setti…
Browse files Browse the repository at this point in the history
…ngs are not updated in Property Grid after removing them by using the edit choices popup dialog on a design surface fix #5879
  • Loading branch information
andrewtelnov committed Sep 13, 2024
1 parent 91ea4b4 commit 901e863
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
6 changes: 5 additions & 1 deletion packages/survey-creator-core/src/components/matrix-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export class MatrixCellWrapperEditSurvey {
questionJSON[key] = !columnJSON[key];
}
}
column.fromJSON(questionJSON);
for(let key in questionJSON) {
if(!Helpers.isTwoValueEquals(questionJSON[key], columnJSON[key])) {
column[key] = questionJSON[key];
}
}
matrix.onColumnCellTypeChanged(column);
this.creator.setModified({ type: "MATRIX_CELL_EDITOR", column: column });
}
Expand Down
38 changes: 33 additions & 5 deletions packages/survey-creator-core/tests/question-editors.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ test("Edit matrix cell question", (): any => {
let type;
let columnName;
creator.onModified.add((sender, options) => {
modifiedCounter++;
type = options.type;
columnName = options.column.name;
if(options.type === "MATRIX_CELL_EDITOR") {
modifiedCounter++;
type = options.type;
columnName = options.column.name;
}
});
creator.onStateChanged.add((sender, options) => {
stateCounter++;
Expand All @@ -195,15 +197,16 @@ test("Edit matrix cell question", (): any => {
expect(matrix.columns[0].cellType).toEqual("radiogroup");
expect(creator.state).toBe("modified");
expect(modifiedCounter).toBe(1);
expect(stateCounter).toBe(1);
expect(stateCounter).toBeGreaterThan(0);
expect(type).toBe("MATRIX_CELL_EDITOR");
expect(columnName).toBe("column1");

stateCounter = 0;
question = matrix.visibleRows[0].cells[0].question;
editSurvey = new MatrixCellWrapperEditSurvey(creator, question, editQuestion.choices[0]);
editSurvey.apply();
expect(modifiedCounter).toBe(1);
expect(stateCounter).toBe(1);
expect(stateCounter).toBe(0);
});
test("Edit matrix cell question & selectAll, other and none", (): any => {
let creator = new CreatorTester();
Expand Down Expand Up @@ -287,3 +290,28 @@ test("Edit matrix cell question & showInMultipleColumns, #5750", (): any => {
expect(columnQuestion.showInMultipleColumns).toBeTruthy();
expect(columnQuestion.choices).toHaveLength(5);
});
test("Edit matrix cell question & showInMultipleColumns, #5750", (): any => {
const creator = new CreatorTester();
creator.JSON = {
"elements": [
{
"type": "matrixdropdown",
"name": "q1",
"columns": [{ name: "column1", cellType: "checkbox", showNoneItem: true, choices: [1, 2, 3, 4] }],
"rows": ["row1", "row2"]
}
]
};
const matrix = <QuestionMatrixDropdownModel>creator.survey.getQuestionByName("q1");
creator.selectElement(matrix.columns[0]);
expect(creator.propertyGrid.getQuestionByName("showNoneItem").value).toBeTruthy();
let question = matrix.visibleRows[0].cells[0].question;
let editSurvey = new MatrixCellWrapperEditSurvey(creator, question, matrix.columns[0]);
let editQuestion = <QuestionCheckboxModel>editSurvey.question;
expect(editQuestion.getType()).toEqual("checkbox");
editQuestion.choices = [1, 2];
editQuestion.showNoneItem = false;
editSurvey.apply();
expect(creator.propertyGrid.getQuestionByName("showNoneItem").value).toBeFalsy();
expect(matrix.columns[0].choices).toHaveLength(2);
});

0 comments on commit 901e863

Please sign in to comment.