Skip to content

Commit

Permalink
Hide the Choices collection when changing the matrix cell type from D…
Browse files Browse the repository at this point in the history
…ropdown to Text fix #8560 (#8567)
andrewtelnov authored Jul 16, 2024
1 parent aa269da commit ccce5c2
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/question_matrixdropdownbase.ts
Original file line number Diff line number Diff line change
@@ -1245,6 +1245,9 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
val = val.toLowerCase();
this.setPropertyValue("cellType", val);
}
isSelectCellType(): boolean {
return Serializer.isDescendantOf(this.cellType, "selectbase");
}
private updateColumnsCellType() {
for (var i = 0; i < this.columns.length; i++) {
this.columns[i].defaultCellTypeChanged();
@@ -2589,7 +2592,7 @@ Serializer.addClass(
},
{ name: "horizontalScroll:boolean", visible: false, },
{
name: "choices:itemvalue[]", uniqueProperty: "value",
name: "choices:itemvalue[]", uniqueProperty: "value", visibleIf: (obj): boolean => obj.isSelectCellType()
},
{ name: "placeholder", alternativeName: "optionsCaption", serializationProperty: "locPlaceholder" },
{
21 changes: 20 additions & 1 deletion tests/question_matrixdropdownbasetests.ts
Original file line number Diff line number Diff line change
@@ -1530,4 +1530,23 @@ QUnit.test("Check if errors disappered in the cells in the current row on changi
q2.value = 1;
assert.equal(q1.errors.length, 0, "q1 errors #2");
assert.equal(q2.errors.length, 0, "q2 errors #2");
});
});
QUnit.test("choices property visibility, Bug#8560", function (assert) {
const survey = new SurveyModel({
elements: [
{
type: "matrixdynamic",
name: "matrix"
}
]
});
const matrix = <QuestionMatrixDynamicModel>survey.getQuestionByName("matrix");
const prop = Serializer.findProperty("matrixdynamic", "choices");
assert.equal(prop.isVisible("", matrix), true, "#1");
matrix.cellType = "text";
assert.equal(prop.isVisible("", matrix), false, "#2");
matrix.cellType = "checkbox";
assert.equal(prop.isVisible("", matrix), true, "#3");
matrix.cellType = "comment";
assert.equal(prop.isVisible("", matrix), false, "#4");
});

0 comments on commit ccce5c2

Please sign in to comment.