mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-40741 Form rule Validate form doesn't do anything (#11788)
This commit is contained in:
@@ -349,4 +349,42 @@ describe('DropdownWidgetComponent', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('showAllValidationErrors', () => {
|
||||
it('should mark dropdownControl as touched when showAllValidationErrors is true', () => {
|
||||
const form = new FormModel();
|
||||
widget.field = new FormFieldModel(form, {
|
||||
id: 'dropdown-id',
|
||||
name: 'dropdown-name',
|
||||
type: FormFieldTypes.DROPDOWN,
|
||||
required: true,
|
||||
options: fakeOptionList
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(widget.dropdownControl.touched).toBe(false);
|
||||
|
||||
form.showAllValidationErrors = true;
|
||||
widget.updateReactiveFormControl();
|
||||
|
||||
expect(widget.dropdownControl.touched).toBe(true);
|
||||
});
|
||||
|
||||
it('should not mark dropdownControl as touched when showAllValidationErrors is false', () => {
|
||||
const form = new FormModel();
|
||||
widget.field = new FormFieldModel(form, {
|
||||
id: 'dropdown-id',
|
||||
name: 'dropdown-name',
|
||||
type: FormFieldTypes.DROPDOWN,
|
||||
required: true,
|
||||
options: fakeOptionList
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
form.showAllValidationErrors = false;
|
||||
widget.updateReactiveFormControl();
|
||||
|
||||
expect(widget.dropdownControl.touched).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,6 +100,9 @@ export class DropdownWidgetComponent extends WidgetComponent implements OnInit,
|
||||
|
||||
updateReactiveFormControl(): void {
|
||||
this.updateFormControlState();
|
||||
if (this.field?.form?.showAllValidationErrors) {
|
||||
this.dropdownControl.markAsTouched();
|
||||
}
|
||||
this.handleErrors();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user