Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The maxLength property doesn't work for Password input fields fix #7728 #7737

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/question_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class QuestionTextModel extends QuestionTextBase {
}
}
public getMaxLength(): any {
if(this.inputType !== "text") return null;
if(!this.isTextInput) return null;
return super.getMaxLength();
}
public runCondition(values: HashTable<any>, properties: HashTable<any>) {
Expand Down
14 changes: 13 additions & 1 deletion tests/question_texttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,16 @@ QUnit.test("Set empty text", function(assert) {
QUnit.test("Text Question KeyHandler exists", function (assert) {
const q = new QuestionTextModel("q1");
assert.ok(q["onTextKeyDownHandler"], "we need this handler for using in Survey Creator");
});
});
QUnit.test("Test maxLength & getMaxLength", function (assert) {
const q = new QuestionTextModel("q1");
q.maxLength = 10;
assert.equal(q.isTextInput, true, "isTextInput - text");
assert.equal(q.getMaxLength(), 10, "getMaxLength() - text");
q.inputType = "color";
assert.equal(q.isTextInput, false, "isTextInput - color");
assert.equal(q.getMaxLength(), null, "getMaxLength() - color");
q.inputType = "password";
assert.equal(q.isTextInput, true, "isTextInput - password");
assert.equal(q.getMaxLength(), 10, "getMaxLength() - password");
});
Loading