From 6fc86c8c50a0dbcb62d995b785f02d3bad6ae66a Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 20 Oct 2023 17:33:28 +0400 Subject: [PATCH] Work for #7184: fix max size error doesnt update question css classes (#7203) --- src/question.ts | 5 +---- tests/questionFileTests.ts | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/question.ts b/src/question.ts index f10f2899d2..8cefaced43 100644 --- a/src/question.ts +++ b/src/question.ts @@ -172,7 +172,7 @@ export class Question extends SurveyElement this.initCommentFromSurvey(); } ); - this.registerFunctionOnPropertiesValueChanged(["no", "readOnly"], () => { + this.registerFunctionOnPropertiesValueChanged(["no", "readOnly", "hasVisibleErrors", "containsErrors"], () => { this.updateQuestionCss(); }); this.registerPropertyChangedHandlers(["isMobile"], () => { this.onMobileChanged(); }); @@ -2049,9 +2049,6 @@ export class Question extends SurveyElement } } this.updateContainsErrors(); - if (oldHasErrors != errors.length > 0) { - this.updateQuestionCss(); - } if (this.isCollapsed && rec && fireCallback && errors.length > 0) { this.expand(); } diff --git a/tests/questionFileTests.ts b/tests/questionFileTests.ts index 948ab337e3..eb96e9937c 100644 --- a/tests/questionFileTests.ts +++ b/tests/questionFileTests.ts @@ -1747,4 +1747,27 @@ QUnit.test("QuestionFile allowImagesPreview and allowCameraAccess", function (as assert.equal(prop1.isVisible(undefined, q1), false); const prop2 = Serializer.getProperty("file", "allowCameraAccess"); assert.equal(prop2.visible, false); +}); + +QUnit.test("QuestionFile maxSize error doesnt update question css classes", function (assert) { + const survey = new SurveyModel({ + elements: [ + { type: "file", name: "q1", maxSize: 3 }, + ] + }); + survey.css = { + question: { + hasError: "root-error", + hasErrorTop: "root-error-top" + } + }; + const question = survey.getAllQuestions()[0]; + assert.notOk(question.cssRoot.includes("root-error")); + assert.notOk(question.cssRoot.includes("root-error-top")); + question["allFilesOk"]([{ size: 2 }]); + assert.notOk(question.cssRoot.includes("root-error")); + assert.notOk(question.cssRoot.includes("root-error-top")); + question["allFilesOk"]([{ size: 4 }]); + assert.ok(question.cssRoot.includes("root-error")); + assert.ok(question.cssRoot.includes("root-error-top")); }); \ No newline at end of file