From fc26eb42f335ec43829f85dfa42746c36ac4f03a Mon Sep 17 00:00:00 2001 From: Vito Date: Fri, 8 Jun 2018 14:10:32 +0100 Subject: [PATCH] [ADF-3123] removed default choice for the first radio button (#3462) --- lib/core/form/components/form.component.spec.ts | 2 +- .../form/components/widgets/core/form-field.model.spec.ts | 4 ++-- lib/core/form/components/widgets/core/form-field.model.ts | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/core/form/components/form.component.spec.ts b/lib/core/form/components/form.component.spec.ts index 862a7c1be3..8c07f8b966 100644 --- a/lib/core/form/components/form.component.spec.ts +++ b/lib/core/form/components/form.component.spec.ts @@ -822,7 +822,7 @@ describe('FormComponent', () => { let labelField = formFields.find(field => field.id === 'label'); let radioField = formFields.find(field => field.id === 'radio'); expect(labelField.value).toBe('empty'); - expect(radioField.value).toBe('option_1'); + expect(radioField.value).toBeNull(); let formValues: any = {}; formValues.label = { diff --git a/lib/core/form/components/widgets/core/form-field.model.spec.ts b/lib/core/form/components/widgets/core/form-field.model.spec.ts index 95e8852cbe..72856d081a 100644 --- a/lib/core/form/components/widgets/core/form-field.model.spec.ts +++ b/lib/core/form/components/widgets/core/form-field.model.spec.ts @@ -328,7 +328,7 @@ describe('FormFieldModel', () => { expect(form.values['radio-1']).toEqual(field.options[1]); }); - it('should update form with the first radio button value', () => { + it('radio button value should be null when no default is set', () => { let form = new FormModel(); let field = new FormFieldModel(form, { id: 'radio-2', @@ -340,7 +340,7 @@ describe('FormFieldModel', () => { }); field.value = 'missing'; - expect(form.values['radio-2']).toEqual(field.options[0]); + expect(form.values['radio-2']).toBeUndefined(); }); it('should not update form with display-only field value', () => { diff --git a/lib/core/form/components/widgets/core/form-field.model.ts b/lib/core/form/components/widgets/core/form-field.model.ts index ec9cc3bd63..07cdf72030 100644 --- a/lib/core/form/components/widgets/core/form-field.model.ts +++ b/lib/core/form/components/widgets/core/form-field.model.ts @@ -317,8 +317,6 @@ export class FormFieldModel extends FormWidgetModel { opt.id === value || opt.name === value || (value && (opt.id === value.id || opt.name === value.name))); if (entry.length > 0) { value = entry[0].id; - } else { - value = this.options[0] ? this.options[0].id : json.value; } }