diff --git a/src/question.ts b/src/question.ts index 5482dd1388..409143ddc0 100644 --- a/src/question.ts +++ b/src/question.ts @@ -511,7 +511,7 @@ export class Question extends SurveyElement private resetValueIfExpression: ExpressionRunner; private isRunningResetValueIf: boolean; public runTriggers(name: string, value: any): void { - if(this.isRunningResetValueIf || !this.isVisible || this.isReadOnly || !this.resetValueIf || this.isEmpty() || this.isSettingQuestionValue) return; + if(this.isRunningResetValueIf || this.isReadOnly || !this.resetValueIf || this.isEmpty() || this.isSettingQuestionValue) return; if(this.parentQuestion && this.parentQuestion.getValueName() === name) return; if(!this.resetValueIfExpression) { this.resetValueIfExpression = new ExpressionRunner(this.resetValueIf); diff --git a/src/survey.ts b/src/survey.ts index 1a172b7482..4373769a02 100644 --- a/src/survey.ts +++ b/src/survey.ts @@ -5686,7 +5686,7 @@ export class SurveyModel extends SurveyElementCore } private runQuestionsTriggers(name: string, value: any): void { if(this.isDisplayMode || this.isDesignMode) return; - const questions = this.getAllQuestions(true); + const questions = this.getAllQuestions(); questions.forEach(q => q.runTriggers(name, value)); } private checkIfNewPagesBecomeVisible(oldCurrentPageIndex: number) { diff --git a/tests/question_customtests.ts b/tests/question_customtests.ts index a97834d8bf..70e142a3c0 100644 --- a/tests/question_customtests.ts +++ b/tests/question_customtests.ts @@ -981,14 +981,15 @@ QUnit.test("Single: onAfterRender and onAfterRenderContentElement", function ( elements: [{ type: "newquestion", name: "q1" }], }); var q = survey.getAllQuestions()[0]; - q.afterRender(5); + const el: HTMLElement = ({ a: 5 }); + q.afterRender(el); assert.equal( afterRenderQuestion.name, "q1", "onAfterRender, question parameter is correct" ); assert.equal( - afterRenderHtmlElement, + (afterRenderHtmlElement).a, 5, "onAfterRender, htmlElement parameter is correct" ); @@ -1046,14 +1047,15 @@ QUnit.test("Composite: onAfterRender and onAfterRenderContentElement", function elements: [{ type: "fullname", name: "q1" }], }); var q = survey.getAllQuestions()[0]; - q.afterRender(5); + const el: HTMLElement = ({ a: 5 }); + q.afterRender(el); assert.equal( afterRenderQuestion.name, "q1", "onAfterRender, question parameter is correct" ); assert.equal( - afterRenderHtmlElement, + (afterRenderHtmlElement).a, 5, "onAfterRender, htmlElement parameter is correct" ); diff --git a/tests/surveyquestiontests.ts b/tests/surveyquestiontests.ts index 637a7ba968..c29efbcaea 100644 --- a/tests/surveyquestiontests.ts +++ b/tests/surveyquestiontests.ts @@ -7325,6 +7325,27 @@ QUnit.test("question.resetValueIf, cycle calls", function (assert) { assert.equal(q3.isEmpty(), true, "q2.value #3"); assert.equal(q3.isEmpty(), true, "q3.value #3"); }); +QUnit.test("question.resetValueIf and invisibleQuestions", function (assert) { + const survey = new SurveyModel({ + elements: [{ + "name": "q1", + "type": "text" + }, + { + "name": "q2", + "type": "text", + "resetValueIf": "{q1} = 1", + "visible": false + } + ] }); + const q1 = survey.getQuestionByName("q1"); + const q2 = survey.getQuestionByName("q2"); + q2.value = "abc"; + assert.equal(q2.value, "abc", "value is set"); + q1.value = 1; + assert.equal(q2.isEmpty(), true, "value is cleared"); +}); + QUnit.test("question.isReady & async functions in expression", function (assert) { var returnResult1: (res: any) => void; var returnResult2: (res: any) => void;