Skip to content

Commit

Permalink
resolve #8425 Impossible to enter any answer in Single-Line Input (In…
Browse files Browse the repository at this point in the history
…put Type: Number) because the Input Mask Settings are not reset (#8427)

Co-authored-by: OlgaLarina <[email protected]>
  • Loading branch information
OlgaLarina and OlgaLarina authored Jun 18, 2024
1 parent 39d819a commit fde198b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/question_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class QuestionTextModel extends QuestionTextBase {
@property() inputTextAlignment: "left" | "right" | "auto";

get maskTypeIsEmpty(): boolean {
return this.maskType === "none";
return this.maskType === "none" || this.inputType !== "text";
}

/**
Expand Down Expand Up @@ -151,6 +151,7 @@ export class QuestionTextModel extends QuestionTextBase {
this.max = undefined;
this.step = undefined;
}
this.updateMaskAdapter();
}
public getMaxLength(): any {
if(!this.isTextInput) return null;
Expand Down
22 changes: 22 additions & 0 deletions tests/mask/mask_settings_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ QUnit.test("Switch mask type", function (assert) {
assert.equal(q.maskSettings instanceof InputMaskBase, true);
});

QUnit.test("Switch input type", function (assert) {
const testInput = document.createElement("input");
const q = new QuestionTextModel("q1");
q["input"] = testInput;
assert.ok(q.maskTypeIsEmpty);
assert.ok(!q["maskInputAdapter"]);

q.maskType = "pattern";
assert.ok(!q.maskTypeIsEmpty);
assert.ok(q["maskInputAdapter"]);

q.inputType = "date";
assert.ok(q.maskTypeIsEmpty);
assert.ok(!q["maskInputAdapter"]);

q.inputType = "text";
assert.ok(!q.maskTypeIsEmpty);
assert.ok(q["maskInputAdapter"]);

testInput.remove();
});

QUnit.test("Datetime mask: value & inputValue", function (assert) {
const q = new QuestionTextModel("q1");
q.maskType = "datetime";
Expand Down

0 comments on commit fde198b

Please sign in to comment.