From bb2acacf840186b0da26c612f7d34e4565ebbef0 Mon Sep 17 00:00:00 2001 From: Alexey Romanoff Date: Fri, 21 Jan 2022 12:54:54 +0300 Subject: [PATCH 1/2] fix(ajsf/core): layout functions: buildTitleMap: use empty string to conform HTML behaviour use empty string instead of null for non required empty values to conform HTML behaviour Fixes #333 --- projects/ajsf-core/src/lib/shared/layout.functions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/ajsf-core/src/lib/shared/layout.functions.ts b/projects/ajsf-core/src/lib/shared/layout.functions.ts index 59fc2afc..f5d47654 100755 --- a/projects/ajsf-core/src/lib/shared/layout.functions.ts +++ b/projects/ajsf-core/src/lib/shared/layout.functions.ts @@ -1062,7 +1062,7 @@ export function buildTitleMap( } } if (!fieldRequired && !hasEmptyValue) { - newTitleMap.unshift({ name: 'None', value: null }); + newTitleMap.unshift({ name: 'None', value: '' }); } return newTitleMap; } From c5537bf44421a52fe4beb4d52cbbcf4270be2772 Mon Sep 17 00:00:00 2001 From: Alexey Romanoff Date: Fri, 21 Jan 2022 12:57:20 +0300 Subject: [PATCH 2/2] fix(ajsf/core): json-schema-form service: initializeControl: fix null values in enum fromControl-s force formControl value to empty string when it's null and if the control has enum Fixes #333 --- projects/ajsf-core/src/lib/json-schema-form.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/ajsf-core/src/lib/json-schema-form.service.ts b/projects/ajsf-core/src/lib/json-schema-form.service.ts index a20eaa77..dfe2897c 100755 --- a/projects/ajsf-core/src/lib/json-schema-form.service.ts +++ b/projects/ajsf-core/src/lib/json-schema-form.service.ts @@ -544,6 +544,10 @@ export class JsonSchemaFormService { ctx.formControl = this.getFormControl(ctx); ctx.boundControl = bind && !!ctx.formControl; if (ctx.formControl) { + if (ctx.options.enum && ctx.formControl.value === null) { + ctx.formControl.value = ''; + } + ctx.controlName = this.getFormControlName(ctx); ctx.controlValue = ctx.formControl.value; ctx.controlDisabled = ctx.formControl.disabled;