Skip to content

Commit

Permalink
Fix: Carry forward doesn't work properly with the predefined survey.d…
Browse files Browse the repository at this point in the history
…ata #2648
  • Loading branch information
andrewtelnov committed Feb 4, 2021
1 parent e3a2a4d commit 785527f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/question_baseselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,11 @@ export class QuestionSelectBase extends Question {
}
this.isUpdatingChoicesDependedQuestions = false;
}
onSurveyValueChanged(newValue: any) {
super.onSurveyValueChanged(newValue);
if (this.isLoadingFromJson) return;
this.updateChoicesDependedQuestions();
}
protected onVisibleChoicesChanged() {
if (this.isLoadingFromJson) return;
this.updateVisibleChoices();
Expand Down
17 changes: 17 additions & 0 deletions tests/surveyquestiontests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4715,6 +4715,23 @@ QUnit.test(
assert.equal(q2.visibleChoices.length, 3, "Get choices from q2");
}
);
QUnit.test("choicesFromQuestion predefined data, Bug#2648", function (assert) {
var survey = new SurveyModel({
elements: [
{ type: "checkbox", name: "q1", choices: [1, 2, 3, 4, 5] },
{
type: "checkbox",
name: "q2",
choicesFromQuestion: "q1",
choicesFromQuestionMode: "selected",
},
],
});
survey.data = { q1: [1, 3, 5] };
var q2 = <QuestionCheckboxModel>survey.getQuestionByName("q2");
assert.ok(q2.choicesFromQuestion, "choicesFromQuestion is here");
assert.equal(q2.visibleChoices.length, 3, "Get choices from q1.value");
});
QUnit.test("text question dataList", function (assert) {
var survey = new SurveyModel({
elements: [
Expand Down

0 comments on commit 785527f

Please sign in to comment.