Skip to content

Commit

Permalink
Work for #7184: fix max size error doesnt update question css classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dk981234 committed Oct 20, 2023
1 parent 8a0a652 commit 423ad86
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class Question extends SurveyElement<Question>
this.initCommentFromSurvey();
}
);
this.registerFunctionOnPropertiesValueChanged(["no", "readOnly"], () => {
this.registerFunctionOnPropertiesValueChanged(["no", "readOnly", "hasVisibleErrors", "containsErrors"], () => {
this.updateQuestionCss();
});
this.registerPropertyChangedHandlers(["isMobile"], () => { this.onMobileChanged(); });
Expand Down Expand Up @@ -2047,9 +2047,6 @@ export class Question extends SurveyElement<Question>
}
}
this.updateContainsErrors();
if (oldHasErrors != errors.length > 0) {
this.updateQuestionCss();
}
if (this.isCollapsed && rec && fireCallback && errors.length > 0) {
this.expand();
}
Expand Down
23 changes: 23 additions & 0 deletions tests/questionFileTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1693,4 +1693,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"));
});

0 comments on commit 423ad86

Please sign in to comment.