Skip to content

Commit

Permalink
Input Type and Masked Input - Enable Pattern Mask Input for Phone Num…
Browse files Browse the repository at this point in the history
…ber Input Type (#8447)

* resolve #8431 Input Type and Masked Input - Enable Pattern Mask Input for Phone Number Input Type

* work for  #8431 Input Type and Masked Input - Enable Pattern Mask Input for Phone Number Input Type

---------

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

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

/**
Expand Down Expand Up @@ -773,7 +777,7 @@ Serializer.addClass(
visibleIndex: 0,
dependsOn: "inputType",
visibleIf: (obj: any) => {
return obj.inputType === "text";
return obj.inputType === "text" || obj.inputType === "tel";
}
},
{
Expand All @@ -782,7 +786,7 @@ Serializer.addClass(
visibleIndex: 1,
dependsOn: "inputType",
visibleIf: (obj: any) => {
return obj.inputType === "text";
return obj.inputType === "text" || obj.inputType === "tel";
},
onGetValue: function (obj: any) {
return obj.maskSettings.getData();
Expand Down
16 changes: 10 additions & 6 deletions tests/mask/mask_settings_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,20 @@ QUnit.test("Switch input type", function (assert) {
assert.ok(!q["maskInputAdapter"]);

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

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

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

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

testInput.remove();
});
Expand Down

0 comments on commit 19c15d2

Please sign in to comment.