diff --git a/packages/survey-creator-core/src/property-grid/condition-survey.ts b/packages/survey-creator-core/src/property-grid/condition-survey.ts index 14e6b4ac09..d5fdbe2252 100644 --- a/packages/survey-creator-core/src/property-grid/condition-survey.ts +++ b/packages/survey-creator-core/src/property-grid/condition-survey.ts @@ -212,7 +212,7 @@ export class ConditionEditorItemsBuilder { function questionValueVisibleIf(params: any): boolean { if (params.length !== 2) return false; - if (!params[0] || !params[1]) return false; + if (Helpers.isValueEmpty(params[0]) || !params[1]) return false; return params[1] !== "empty" && params[1] !== "notempty"; } diff --git a/packages/survey-creator-core/tests/tabs/logic.tests.ts b/packages/survey-creator-core/tests/tabs/logic.tests.ts index 5a28847d1b..b059662ddd 100644 --- a/packages/survey-creator-core/tests/tabs/logic.tests.ts +++ b/packages/survey-creator-core/tests/tabs/logic.tests.ts @@ -1985,6 +1985,34 @@ test("LogicUI: edit matrix column visibleIf. Filter selector if there is a conte colSelector = (actionPanel.getQuestionByName("elementSelector")); expect(colSelector.choices).toHaveLength(3 + 2); }); +test("A question with name '0' doesn't appear correctly within a condition editor Bug#6430", () => { + const survey = new SurveyModel({ + elements: [ + { + type: "radiogroup", name: "0", choices: ["a", "b", "c", "d"] }, + { type: "text", name: "q2" } + ] + }); + const logic = new SurveyLogicUI(survey); + logic.addNew(); + const expressionEditor = logic.expressionEditor; + const firstExpressionPanel = expressionEditor.panel.panels[0]; + const questionName = firstExpressionPanel.getQuestionByName("questionName"); + questionName.value = 0; + const questionValue = firstExpressionPanel.getQuestionByName("questionValue"); + expect(questionValue).toBeTruthy(); + expect(questionValue.isVisible).toBeTruthy(); + expect(questionValue.getType()).toBe("radiogroup"); + expect(questionValue.choices).toHaveLength(4); + questionValue.value = "d"; + const itemEditor = logic.itemEditor; + let actionPanel = itemEditor.panels[0]; + actionPanel.getQuestionByName("logicTypeName").value = "question_visibility"; + actionPanel.getQuestionByName("elementSelector").value = "q2"; + logic.saveEditableItem(); + const q2 = survey.getQuestionByName("q2"); + expect(q2.visibleIf).toEqual("{0} = 'd'"); +}); test("LogicUI: edit matrix column visibleIf. Filter logic types and delete actions if there is a context", () => { const survey = new SurveyModel({ elements: [