From 8b20412339ebcfe2a7176a67c0d8a2e14cf34d89 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 13 Nov 2023 14:08:49 +0200 Subject: [PATCH] It is impossible to change colCount property default value fix #7333 (#7334) --- src/question_baseselect.ts | 2 +- tests/jsonobjecttests.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/question_baseselect.ts b/src/question_baseselect.ts index 7147e6c512..d56580396d 100644 --- a/src/question_baseselect.ts +++ b/src/question_baseselect.ts @@ -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; diff --git a/tests/jsonobjecttests.ts b/tests/jsonobjecttests.ts index f4912e4e78..67be8f4250 100644 --- a/tests/jsonobjecttests.ts +++ b/tests/jsonobjecttests.ts @@ -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((survey.jsonErrors[0]).propertyName, "pages", "Correct property name #1"); assert.equal((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"); }); \ No newline at end of file