From 2d50643f789637c1c848b177d30c7f6c48bbf1d5 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 18 Oct 2023 18:06:37 +0300 Subject: [PATCH] Multiple Textboxes: minValueExpression doesn't apply when the question is inside a panel fix #7176 (#7177) --- src/question_multipletext.ts | 6 +++++- tests/question_multipletexttests.ts | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/question_multipletext.ts b/src/question_multipletext.ts index 99a5c72f1c..410db79de5 100644 --- a/src/question_multipletext.ts +++ b/src/question_multipletext.ts @@ -17,7 +17,7 @@ import { JsonObject, Serializer, property, propertyArray } from "./jsonobject"; import { QuestionFactory } from "./questionfactory"; import { SurveyError } from "./survey-error"; import { ILocalizableOwner, LocalizableString } from "./localizablestring"; -import { Helpers } from "./helpers"; +import { HashTable, Helpers } from "./helpers"; import { CssClassBuilder } from "./utils/cssClassBuilder"; import { settings } from "./settings"; @@ -586,6 +586,10 @@ export class QuestionMultipleTextModel extends Question this.items[i].onValueChanged(itemValue); } } + public runCondition(values: HashTable, properties: HashTable): void { + super.runCondition(values, properties); + this.items.forEach(item => item.editor.runCondition(values, properties)); + } protected getIsRunningValidators(): boolean { if (super.getIsRunningValidators()) return true; for (var i = 0; i < this.items.length; i++) { diff --git a/tests/question_multipletexttests.ts b/tests/question_multipletexttests.ts index 16e5403cc5..a004649e88 100644 --- a/tests/question_multipletexttests.ts +++ b/tests/question_multipletexttests.ts @@ -192,3 +192,26 @@ QUnit.test("Load min/maxValueExpression from JSON", (assert) => { assert.equal(question.items[0].minValueExpression, 1); assert.equal(question.items[0].maxValueExpression, 10); }); +QUnit.test("min/maxValueExpression executing", (assert) => { + const survey = new SurveyModel({ + questions: [ + { + type: "multipletext", + name: "q1", + items: [ + { + name: "item1" + }, + { + name: "item2", + minValueExpression: "{q1.item1}" + } + ] + } + ] + }); + const q1 = survey.getQuestionByName("q1"); + q1.items[0].value = 10; + q1.items[1].value = 5; + assert.equal(q1.items[1].editor.hasErrors(), true); +});