Skip to content

Commit

Permalink
defaultValueExpression should be ignored in case of preloaded data (1…
Browse files Browse the repository at this point in the history
….9.107 regression) fix #6941
  • Loading branch information
andrewtelnov committed Sep 12, 2023
1 parent aca20d8 commit dae7f87
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ export class Question extends SurveyElement<Question>
newValue = this.valueFromDataCallback(newValue);
}
if(!this.checkIsValueCorrect(newValue)) return;
this.isChangingViaDefaultValue = true;
this.isChangingViaDefaultValue = this.isValueEmpty(newValue);
this.setQuestionValue(this.valueFromData(newValue));
this.isChangingViaDefaultValue = false;
this.updateDependedQuestions();
Expand Down
15 changes: 14 additions & 1 deletion tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17674,4 +17674,17 @@ QUnit.test("Copy panel with invisible questions at design-time", (assert): any =
assert.equal(q3.visible, false, "q3.visible = false");
assert.equal(q3.isVisible, true, "q3.isVisible = true");
assert.equal(q3.getPropertyValue("isVisible"), true, "q3.isVisible via getPropertyValue");
});
});
QUnit.test("Use variables as default values in expression", function (assert) {
const survey = new SurveyModel({
elements: [
{
type: "text",
name: "q1",
defaultValueExpression: "1",
}]
});
survey.data = { q1: 2 };
const q1 = survey.getQuestionByName("q1");
assert.equal(q1.value, 2, "Get data from survey");
});

0 comments on commit dae7f87

Please sign in to comment.