Skip to content

Commit

Permalink
Questions within Custom Components do not display survey variable val…
Browse files Browse the repository at this point in the history
…ues fix #7640
  • Loading branch information
andrewtelnov committed Jan 9, 2024
1 parent 18b7759 commit 5933e91
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/question_custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,8 @@ export class QuestionCustomModel extends QuestionCustomModelBase {
return this.contentQuestion;
}
protected getDefaultTitle(): string {
if(this.hasJSONTitle && this.contentQuestion) return this.contentQuestion.title;
if(this.hasJSONTitle && this.contentQuestion)
return this.getProcessedText(this.contentQuestion.title);
return super.getDefaultTitle();
}
setValue(name: string, newValue: any, locNotification: any, allowNotifyValueChanged?: boolean): any {
Expand Down
22 changes: 22 additions & 0 deletions tests/question_customtests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2658,3 +2658,25 @@ QUnit.test("showPreview & default value, #7508", function (assert) {
assert.equal(contentQuestion.value, "edf", "contentQuestion.value #4");
ComponentCollection.Instance.clear();
});
QUnit.test("showPreview & default value, #7640", function (assert) {
ComponentCollection.Instance.add({
name: "customtext",
questionJSON: {
type: "text",
title: "abc={abc}"
},
});

const survey = new SurveyModel({
elements: [
{ type: "customtext", name: "q1" }
]
});
const q1 = <QuestionCustomModel>survey.getQuestionByName("q1");
const contentQuestion = <QuestionTextModel>q1.contentQuestion;
survey.setVariable("abc", 123);
assert.equal(contentQuestion.locTitle.renderedHtml, "abc=123", "contentQuestion.title");
assert.equal(q1.locTitle.renderedHtml, "abc=123", "q1.title");

ComponentCollection.Instance.clear();
});

0 comments on commit 5933e91

Please sign in to comment.