Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"None" choice in checkbox question is not deselected on clicking on i… #8439

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
});
Loading