Skip to content

Commit

Permalink
work for #4842
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed Feb 8, 2024
1 parent 9337790 commit b0c6330
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/mask/mask_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class MaskSettings extends Base implements IMaskSettings {
return "masksettings";
}
public get isEmpty(): boolean {
return this.type === "none";
return !this.type || this.type === "none";
}
public setData(json: any) {
// this.clear();
Expand Down Expand Up @@ -88,7 +88,7 @@ Serializer.addClass(
},
{ name: "dataToSave",
choices: ["masked", "unmasked"],
defaultValue: "unmasked",
default: "unmasked",
dependsOn: "type",
visibleIf: function(obj: any) {
if (!obj) return false;
Expand Down
26 changes: 19 additions & 7 deletions src/question_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,30 @@ export class QuestionTextModel extends QuestionTextBase {
private maxValueRunner: ExpressionRunner;
private maskInputAdapter: InputElementAdapter;

private createMaskAdapter() {
if (this.maskInstance) {
this.maskInputAdapter = new InputElementAdapter(this.maskInstance as InputMaskBase, this.input, this.value);
}
}
private deleteMaskAdapter() {
if (this.maskInputAdapter) {
this.maskInputAdapter.dispose();
this.maskInputAdapter = undefined;
}
}
private updateMaskAdapter() {
this.deleteMaskAdapter();
this.createMaskAdapter();
}

public get maskSettings(): MaskSettings {
return this.getPropertyValue("maskSettings");
}
public set maskSettings(val: MaskSettings) {
if (!val) return;
this.setNewMaskSettingsProperty();
this.maskSettings.fromJSON(val.toJSON());
this.updateMaskAdapter();
}
private setNewMaskSettingsProperty() {
this.setPropertyValue("maskSettings", this.createMaskSettings());
Expand Down Expand Up @@ -509,17 +526,12 @@ export class QuestionTextModel extends QuestionTextBase {
public afterRenderQuestionElement(el: HTMLElement) {
if (!!el) {
this.input = el instanceof HTMLInputElement ? el : el.querySelector("input");
if (this.maskInstance) {
this.maskInputAdapter = new InputElementAdapter(this.maskInstance as InputMaskBase, this.input, this.value);
}
this.createMaskAdapter();
}
super.afterRenderQuestionElement(el);
}
public beforeDestroyQuestionElement(el: HTMLElement) {
if (this.maskInputAdapter) {
this.maskInputAdapter.dispose();
this.maskInputAdapter = undefined;
}
this.deleteMaskAdapter();
}
}

Expand Down
11 changes: 2 additions & 9 deletions testCafe/validation/focusErroredInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ const json2 = {
frameworks.forEach(framework => {
fixture`${framework} ${title}`.page`${url}${framework}`.beforeEach(
async t => {
await initSurvey(framework, json1);
}
);

test("validate on error", async t => {
let surveyResult;

await initSurvey(framework, json1);
await t
.pressKey("tab")
.pressKey("tab")
Expand All @@ -98,18 +98,11 @@ frameworks.forEach(framework => {
surveyResult = await getSurveyResult();
await t.expect(surveyResult).eql({ q1: "1" });
});
});

frameworks.forEach(framework => {
fixture`${framework} ${title}`.page`${url}${framework}`.beforeEach(
async t => {
await initSurvey(framework, json2);
}
);

test("validate on error in matrix", async t => {
let surveyResult;

await initSurvey(framework, json2);
await t
.pressKey("tab")
.pressKey("tab")
Expand Down

0 comments on commit b0c6330

Please sign in to comment.