From fde198b34af7defaeb6309b9e407619b2bba5e54 Mon Sep 17 00:00:00 2001 From: OlgaLarina Date: Tue, 18 Jun 2024 09:47:39 +0300 Subject: [PATCH] resolve #8425 Impossible to enter any answer in Single-Line Input (Input Type: Number) because the Input Mask Settings are not reset (#8427) Co-authored-by: OlgaLarina --- src/question_text.ts | 3 ++- tests/mask/mask_settings_tests.ts | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) 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";