diff --git a/src/question_text.ts b/src/question_text.ts index 85befe380a..cf95cfc248 100644 --- a/src/question_text.ts +++ b/src/question_text.ts @@ -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"; } /** @@ -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; diff --git a/tests/mask/mask_settings_tests.ts b/tests/mask/mask_settings_tests.ts index 956ccd2726..6339ad9ad9 100644 --- a/tests/mask/mask_settings_tests.ts +++ b/tests/mask/mask_settings_tests.ts @@ -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";