Skip to content

Commit

Permalink
"None" choice in checkbox question is not deselected on clicking on i…
Browse files Browse the repository at this point in the history
…t when it is selected fix #8438 (#8439)
  • Loading branch information
andrewtelnov authored Jun 19, 2024
1 parent cbb0ccf commit 9648712
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/question_checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> = [].concat(this.renderedValue || []);
const index = newValue.indexOf(item.value);
Expand Down
19 changes: 19 additions & 0 deletions tests/question_baseselecttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <QuestionCheckboxModel>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");
});

0 comments on commit 9648712

Please sign in to comment.