Skip to content

Commit

Permalink
AAE-29269 Conditional dropdown does not populate after selecting valu…
Browse files Browse the repository at this point in the history
…e in a parent dropdown (#10484)

* AAE-29269 Conditional dropdown does not populate after selecting value in a parent dropdown

* update

* update v2

* validate form

* update units
  • Loading branch information
BSekula authored and VitoAlbano committed Dec 12, 2024
1 parent 419bb78 commit 865ed71
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ describe('FormFieldComponent', () => {

const widgetInstance = component.componentRef.instance;
const updateFormControlState = spyOn(widgetInstance, 'updateReactiveFormControl');
const instanceFormValidation = spyOn(widgetInstance.field.form, 'validateForm');

widgetInstance.formService.formRulesEvent.next();
fixture.detectChanges();

expect(updateFormControlState).toHaveBeenCalled();
expect(instanceFormValidation).toHaveBeenCalled();
});

it('should create custom component instance', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ export class FormFieldComponent implements OnInit, OnDestroy {
const componentType = this.formRenderingService.resolveComponentType(originalField);
if (componentType) {
this.componentRef = this.container.createComponent(componentType);

const instance = this.componentRef.instance;
instance.field = this.field;

instance.fieldChanged.subscribe((field) => {
if (field && this.field.form) {
this.visibilityService.refreshVisibility(field.form);
Expand All @@ -107,7 +109,7 @@ export class FormFieldComponent implements OnInit, OnDestroy {
private updateReactiveFormControlOnFormRulesEvent(instance: any): void {
instance?.formService.formRulesEvent.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
instance?.updateReactiveFormControl();
this.triggerFormFieldChanged(instance.field);
instance?.field?.form.validateForm(instance?.field);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI

private updateFormControlState(): void {
this.dropdownControl.setValidators(this.isRequired() ? [Validators.required] : []);

this.field?.readOnly || this.readOnly
? this.dropdownControl.disable({ emitEvent: false })
: this.dropdownControl.enable({ emitEvent: false });
Expand Down

0 comments on commit 865ed71

Please sign in to comment.