diff --git a/src/question_checkbox.ts b/src/question_checkbox.ts index 2e5cc33393..4abb7e541c 100644 --- a/src/question_checkbox.ts +++ b/src/question_checkbox.ts @@ -167,7 +167,7 @@ export class QuestionCheckboxModel extends QuestionCheckboxBase { } } else { if(this.isNoneItem(item)) { - this.renderedValue = [item.value]; + this.renderedValue = checked ? [item.value] : []; } else { const newValue: Array = [].concat(this.renderedValue || []); const index = newValue.indexOf(item.value); diff --git a/tests/question_baseselecttests.ts b/tests/question_baseselecttests.ts index da661d9d57..65a02d0b3f 100644 --- a/tests/question_baseselecttests.ts +++ b/tests/question_baseselecttests.ts @@ -2160,3 +2160,22 @@ QUnit.test("valuePropertyName & complete trigger, bug#8434", (assert) => { q.renderedValue = ["none"]; assert.equal(survey.calcIsCompleteButtonVisible(), true, "#4"); }); +QUnit.test("Unselect none item, bug#8438", (assert) => { + const survey = new SurveyModel({ + "elements": [ + { + "type": "checkbox", + "name": "q1", + "choices": [1, 2, 3], + "showNoneItem": true + } + ] + }); + const q = survey.getQuestionByName("q1"); + q.clickItemHandler(q.noneItem, true); + assert.deepEqual(q.value, ["none"], "#1"); + q.clickItemHandler(q.noneItem, false); + assert.equal(q.isEmpty(), true, "#2"); + q.clickItemHandler(q.noneItem, true); + assert.deepEqual(q.value, ["none"], "#3"); +});