diff --git a/src/trigger.ts b/src/trigger.ts index 838751f3b5..7ca8cfd4b2 100644 --- a/src/trigger.ts +++ b/src/trigger.ts @@ -188,7 +188,17 @@ export class Trigger extends Base { } protected getUsedVariables(): string[] { if(!this.conditionRunner) return []; - return this.conditionRunner.getVariables(); + const res = this.conditionRunner.getVariables(); + if(Array.isArray(res)) { + const unw = "-unwrapped"; + for(let i = res.length -1; i >= 0; i--) { + const s = res[i]; + if(s.endsWith(unw)) { + res.push(s.substring(0, s.length - unw.length)); + } + } + } + return res; } private createConditionRunner() { if (!!this.conditionRunner) return; diff --git a/tests/question_baseselecttests.ts b/tests/question_baseselecttests.ts index 5fb12a494d..da661d9d57 100644 --- a/tests/question_baseselecttests.ts +++ b/tests/question_baseselecttests.ts @@ -2119,3 +2119,44 @@ QUnit.test("dropdown.clearValue(true) for showCommentArea & showOtherItem, bug#8 assert.equal(q4.value, undefined, "q4.value"); assert.notOk(q4.comment, "q4.comment"); }); +QUnit.test("valuePropertyName & complete trigger, bug#8434", (assert) => { + const survey = new SurveyModel({ + "pages": [ + { + "name": "page1", + "elements": [ + { + "type": "checkbox", + "name": "models", + "choices": [1, 2, 3], + "showNoneItem": true, + "valuePropertyName": "model_id" + } + ] + }, + { + "name": "page2", + "elements": [ + { + "type": "text", + "name": "question1" + } + ] + } + ], + "triggers": [ + { + "type": "complete", + "expression": "{models-unwrapped} = ['none']" + } + ] + }); + const q = survey.getQuestionByName("models"); + assert.equal(survey.calcIsCompleteButtonVisible(), false, "#1"); + q.renderedValue = ["none"]; + assert.equal(survey.calcIsCompleteButtonVisible(), true, "#2"); + q.renderedValue = [1]; + assert.equal(survey.calcIsCompleteButtonVisible(), false, "#3"); + q.renderedValue = ["none"]; + assert.equal(survey.calcIsCompleteButtonVisible(), true, "#4"); +});