Skip to content

Commit

Permalink
Fixed validators that become enabled when made visible even when the …
Browse files Browse the repository at this point in the history
…field isn't configured to be required
  • Loading branch information
alejandro-bulgaris-qcif committed Oct 23, 2023
1 parent 17fa8b6 commit 148732b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions angular-legacy/shared/form/field-contributor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ export class ContributorField extends FieldBase<any> implements CustomValidation
if (this.required) {
this.enableValidators();
} else {
// disable the validators otherwise they'll get enabled on show/hide
this.validators = {};
// if splitting names, attach handler to individual input form control
if (this.splitNames) {
const reqFields = ['family_name', 'given_name'];
Expand Down Expand Up @@ -532,15 +530,17 @@ export class ContributorField extends FieldBase<any> implements CustomValidation
if (!that.visible) {
// restore validators
if (that.formModel) {
if (that.required) {
if(that['enableValidators'] != null && typeof(that['enableValidators']) == 'function') {
that['enableValidators']();
} else {
that.formModel.setValidators(that.validators);
}
setTimeout(() => {
that.setValue(that.formModel.value,false,true)
});
that.formModel.updateValueAndValidity();
}
setTimeout(() => {
that.setValue(that.formModel.value,false,true)
});
that.formModel.updateValueAndValidity();
}
}
}
Expand Down

0 comments on commit 148732b

Please sign in to comment.