Skip to content

Commit

Permalink
survey.maxTextLength should not be applied fo text input type only fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Aug 18, 2023
1 parent e1194fe commit 30b0a60
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/question_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export class QuestionTextModel extends QuestionTextBase {
this.step = undefined;
}
}
public getMaxLength(): any {
if(this.inputType !== "text") return null;
return super.getMaxLength();
}
public runCondition(values: HashTable<any>, properties: HashTable<any>) {
super.runCondition(values, properties);
if (!!this.minValueExpression || !!this.maxValueExpression) {
Expand Down
12 changes: 11 additions & 1 deletion tests/surveyquestiontests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,7 @@ QUnit.test("question.clearIncorrectValues and choicesByUrl", function (assert) {
);
});

QUnit.test("questiontext.maxLength", function (assert) {
QUnit.test("questiontext.maxLength & make it works for text input type only, #6750", function (assert) {
var survey = new SurveyModel();
var page = survey.addNewPage("p1");
var qText = new QuestionTextModel("q1");
Expand All @@ -2447,6 +2447,16 @@ QUnit.test("questiontext.maxLength", function (assert) {
assert.equal(qText.getMaxLength(), null, "makes it undefined");
qText.maxLength = 5;
assert.equal(qText.getMaxLength(), 5, "gets 5 from question");
qText.maxLength = -1;
assert.equal(qText.getMaxLength(), 10, "get from survey again");
qText.inputType = "date";
assert.equal(qText.getMaxLength(), null, "input type is 'date'");
qText.inputType = "number";
assert.equal(qText.getMaxLength(), null, "input type is 'number'");
qText.inputType = "color";
assert.equal(qText.getMaxLength(), null, "input type is 'color'");
qText.inputType = "text";
assert.equal(qText.getMaxLength(), 10, "input type is 'text'");
});

QUnit.test("Display Current/Maximum Allowed Characters when a maximum length is defined for input fields", function (assert) {
Expand Down

0 comments on commit 30b0a60

Please sign in to comment.