diff --git a/packages/survey-creator-core/src/components/matrix-cell.ts b/packages/survey-creator-core/src/components/matrix-cell.ts index a4f006d142..c960be5871 100644 --- a/packages/survey-creator-core/src/components/matrix-cell.ts +++ b/packages/survey-creator-core/src/components/matrix-cell.ts @@ -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 }); } diff --git a/packages/survey-creator-core/tests/question-editors.tests.ts b/packages/survey-creator-core/tests/question-editors.tests.ts index c6c5231844..c6c2973b8d 100644 --- a/packages/survey-creator-core/tests/question-editors.tests.ts +++ b/packages/survey-creator-core/tests/question-editors.tests.ts @@ -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++; @@ -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(); @@ -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 = 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 = 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); +});