Skip to content

Commit 37116d3

Browse files
committed
Condition Property Editor doesn't work when question.valueName equals to {prefix} + question.valueName #953
1 parent 00fd81f commit 37116d3

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/propertyEditors/propertyConditionEditor.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,13 @@ export class ConditionEditorItem {
280280
}
281281
private getQuestionValueByName(questionName: string): string {
282282
var question = this.owner.getQuestionByName(questionName);
283-
if (question && question.name != question.getValueName())
283+
if (
284+
question &&
285+
question.name != question.getValueName() &&
286+
questionName != question.getValueName()
287+
) {
284288
return questionName.replace(question.name, question.getValueName());
289+
}
285290
return questionName;
286291
}
287292
private getValueText(): string {
@@ -387,7 +392,8 @@ export class ConditionEditorItem {
387392
}
388393
}
389394

390-
export class SurveyPropertyConditionEditor extends SurveyPropertyTextEditor
395+
export class SurveyPropertyConditionEditor
396+
extends SurveyPropertyTextEditor
391397
implements IConditionEditorItemOwner {
392398
public showHelpText: boolean = true;
393399
public koTextValue: any;

tests/propertyEditors/propertyConditionEditorTests.ts

+28
Original file line numberDiff line numberDiff line change
@@ -1855,3 +1855,31 @@ QUnit.test(
18551855
);
18561856
}
18571857
);
1858+
QUnit.test(
1859+
"SurveyPropertyConditionEditor, valueName with ':', Bug #953",
1860+
function (assert) {
1861+
var survey = new Survey.Survey({
1862+
elements: [
1863+
{ name: "q1", type: "text", valueName: "profile:q1" },
1864+
{
1865+
name: "q2",
1866+
type: "text",
1867+
},
1868+
],
1869+
});
1870+
var question = survey.getQuestionByName("q2");
1871+
var property = Survey.Serializer.findProperty("question", "visibleIf");
1872+
var editor = new SurveyPropertyConditionEditor(property);
1873+
editor.object = question;
1874+
editor.beforeShow();
1875+
editor.isEditorShowing = true;
1876+
var editorItem = editor.koEditorItems()[0];
1877+
editorItem.questionName = "profile:q1";
1878+
editorItem.value = "1";
1879+
assert.equal(
1880+
editorItem.toString(),
1881+
"{profile:q1} = 1",
1882+
"Condition sets correctly"
1883+
);
1884+
}
1885+
);

0 commit comments

Comments
 (0)