AAE-29269 Conditional dropdown does not populate after selecting value 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
This commit is contained in:
Bartosz Sekula 2024-12-11 10:27:33 -05:00 committed by GitHub
parent e38daa3e08
commit cb56c76d1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 1 deletions

View File

@ -66,11 +66,13 @@ describe('FormFieldComponent', () => {
const widgetInstance = component.componentRef.instance; const widgetInstance = component.componentRef.instance;
const updateFormControlState = spyOn(widgetInstance, 'updateReactiveFormControl'); const updateFormControlState = spyOn(widgetInstance, 'updateReactiveFormControl');
const instanceFormValidation = spyOn(widgetInstance.field.form, 'validateForm');
widgetInstance.formService.formRulesEvent.next(); widgetInstance.formService.formRulesEvent.next();
fixture.detectChanges(); fixture.detectChanges();
expect(updateFormControlState).toHaveBeenCalled(); expect(updateFormControlState).toHaveBeenCalled();
expect(instanceFormValidation).toHaveBeenCalled();
}); });
it('should create custom component instance', () => { it('should create custom component instance', () => {

View File

@ -87,8 +87,10 @@ export class FormFieldComponent implements OnInit, OnDestroy {
const componentType = this.formRenderingService.resolveComponentType(originalField); const componentType = this.formRenderingService.resolveComponentType(originalField);
if (componentType) { if (componentType) {
this.componentRef = this.container.createComponent(componentType); this.componentRef = this.container.createComponent(componentType);
const instance = this.componentRef.instance; const instance = this.componentRef.instance;
instance.field = this.field; instance.field = this.field;
instance.fieldChanged.subscribe((field) => { instance.fieldChanged.subscribe((field) => {
if (field && this.field.form) { if (field && this.field.form) {
this.visibilityService.refreshVisibility(field.form); this.visibilityService.refreshVisibility(field.form);
@ -107,7 +109,7 @@ export class FormFieldComponent implements OnInit, OnDestroy {
private updateReactiveFormControlOnFormRulesEvent(instance: any): void { private updateReactiveFormControlOnFormRulesEvent(instance: any): void {
instance?.formService.formRulesEvent.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => { instance?.formService.formRulesEvent.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
instance?.updateReactiveFormControl(); instance?.updateReactiveFormControl();
this.triggerFormFieldChanged(instance.field); instance?.field?.form.validateForm(instance?.field);
}); });
} }

View File

@ -199,6 +199,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
private updateFormControlState(): void { private updateFormControlState(): void {
this.dropdownControl.setValidators(this.isRequired() ? [Validators.required] : []); this.dropdownControl.setValidators(this.isRequired() ? [Validators.required] : []);
this.field?.readOnly || this.readOnly this.field?.readOnly || this.readOnly
? this.dropdownControl.disable({ emitEvent: false }) ? this.dropdownControl.disable({ emitEvent: false })
: this.dropdownControl.enable({ emitEvent: false }); : this.dropdownControl.enable({ emitEvent: false });