Skip to content

Commit

Permalink
It is impossible to change colCount property default value fix #7333 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Nov 13, 2023
1 parent c073ed9 commit 8b20412
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/question_baseselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1797,7 +1797,7 @@ export class QuestionCheckboxBase extends QuestionSelectBase {
* @see separateSpecialChoices
*/
public get colCount(): number {
return this.getPropertyValue("colCount", this.isFlowLayout ? 0 : 1);
return this.getPropertyValue("colCount", this.isFlowLayout ? 0 : undefined);
}
public set colCount(value: number) {
if (value < 0 || value > 5 || this.isFlowLayout) return;
Expand Down
12 changes: 12 additions & 0 deletions tests/jsonobjecttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3073,4 +3073,16 @@ QUnit.test("Add a page into survey pages array", function (assert) {
assert.equal(survey.jsonErrors.length, 2, "There are JSONs error");
assert.equal((<any>survey.jsonErrors[0]).propertyName, "pages", "Correct property name #1");
assert.equal((<any>survey.jsonErrors[1]).propertyName, "questions", "Correct property name #2");
});
QUnit.test("selectbase colCount property default value", function (assert) {
const q = new QuestionCheckboxModel("q");
assert.equal(q.colCount, 1, "Default value is 1");
const prop = Serializer.findProperty("checkboxbase", "colCount");
const defaultVal = prop.defaultValue;
prop.defaultValue = 0;
assert.equal(q.colCount, 0, "Default value is 0");
prop.defaultValue = 2;
assert.equal(q.colCount, 2, "Default value is 2");
prop.defaultValue = defaultVal;
assert.equal(q.colCount, 1, "Default value is 1 again");
});

0 comments on commit 8b20412

Please sign in to comment.