From 1f450c0593fc351aaefbf278f634c587cca3eae9 Mon Sep 17 00:00:00 2001 From: Diogo Bastos <50139916+DiogoABastos@users.noreply.github.com> Date: Tue, 31 Jan 2023 15:44:31 +0000 Subject: [PATCH] =?UTF-8?q?[AAE-11654]=20Fix=20default=20option=20being=20?= =?UTF-8?q?selectable=20when=20parent=20dropdown=20=E2=80=A6=20(#8146)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [AAE-11654] Fix default option being selectable when parent dropdown has no option selected * [AAE-11654] Remove comment --- .../widgets/dropdown/dropdown-cloud.widget.spec.ts | 10 ++-------- .../widgets/dropdown/dropdown-cloud.widget.ts | 6 +++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts index ad735d2cf8..5c81906bd5 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts @@ -501,10 +501,7 @@ describe('DropdownCloudWidgetComponent', () => { fixture.detectChanges(); await openSelect('child-dropdown-id'); - const defaultOption: any = fixture.debugElement.query(By.css('[id="empty"]')); - expect(widget.field.options).toEqual([{ id: 'empty', name: 'Choose one...' }]); - expect(defaultOption.context.value).toBe(undefined); - expect(defaultOption.context.viewValue).toBe('Choose one...'); + expect(widget.field.options).toEqual([]); }); it('should fetch the options from a rest url for a linked dropdown', async () => { @@ -631,10 +628,7 @@ describe('DropdownCloudWidgetComponent', () => { fixture.detectChanges(); await openSelect('child-dropdown-id'); - const defaultOption: any = fixture.debugElement.query(By.css('[id="empty"]')); - expect(widget.field.options).toEqual([{ id: 'empty', name: 'Choose one...' }]); - expect(defaultOption.context.value).toBe(undefined); - expect(defaultOption.context.viewValue).toBe('Choose one...'); + expect(widget.field.options).toEqual([]); }); describe('Manual - On parent value changes (chain)', () => { diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts index f98666fddd..96319038fb 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts @@ -138,7 +138,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI this.isValidRestType() ? this.persistFieldOptionsFromRestApi() : this.persistFieldOptionsFromManualList(value); } else if (this.isNoneValueSelected(value)) { this.resetRestApiErrorMessage(); - this.addDefaultOption(); + this.resetOptions(); this.resetInvalidValue(); } else { this.field.options = []; @@ -196,8 +196,8 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI return !!this.field.rule.entries.length; } - private addDefaultOption() { - this.field.options = [DEFAULT_OPTION]; + private resetOptions() { + this.field.options = []; this.updateOptions(); }