diff --git a/src/question_checkbox.ts b/src/question_checkbox.ts index c5499adf0b..1a96025d57 100644 --- a/src/question_checkbox.ts +++ b/src/question_checkbox.ts @@ -512,9 +512,11 @@ export class QuestionCheckboxModel extends QuestionCheckboxBase { var res = []; var visItems = this.visibleChoices; for (var i = 0; i < visItems.length; i++) { + const item = visItems[i]; + if(item === this.selectAllItem) continue; var val = visItems[i].value; if (Helpers.isTwoValueEquals(val, this.invisibleOldValues[val])) { - if (!this.isItemSelected(visItems[i])) { + if (!this.isItemSelected(item)) { res.push(val); } delete this.invisibleOldValues[val]; diff --git a/tests/question_baseselecttests.ts b/tests/question_baseselecttests.ts index db837da843..a9163c5939 100644 --- a/tests/question_baseselecttests.ts +++ b/tests/question_baseselecttests.ts @@ -1632,3 +1632,29 @@ QUnit.test("checkbox max(min)SelectedChoices validation", (assert) => { q.maxSelectedChoices = 5; assert.equal(q.maxSelectedChoices, 5, "q.maxSelectedChoices, #5"); }); +QUnit.test("checkbox, selectAll & survey.data, bug#7657", (assert) => { + const survey = new SurveyModel({ + "elements": [ + { + "type": "checkbox", + "name": "q1", + "isRequired": true, + "choices": [ + "One", + "Two", + "Three" + ], + "showNoneItem": true, + "showSelectAllItem": true + } + ] + }); + const q = survey.getQuestionByName("q1"); + q.selectAll(); + q.clickItemHandler(q.choices[2]); + assert.deepEqual(q.value, ["One", "Two"], "q.value, #1"); + assert.deepEqual(survey.data, { q1: ["One", "Two"] }, "survey.data, #1"); + survey.doComplete(); + assert.deepEqual(q.value, ["One", "Two"], "q.value, #2"); + assert.deepEqual(survey.data, { q1: ["One", "Two"] }, "survey.data, #2"); +});