LT-67: Re-validating fields on change only if the form validation has already been called
This commit is contained in:
parent
c6690781f8
commit
92728c4100
@ -17,6 +17,9 @@ OHIF.mixins.form = new OHIF.Mixin({
|
||||
// Set the form identifier flag
|
||||
component.isForm = true;
|
||||
|
||||
// Set the form validated flag
|
||||
component.isValidatedAlready = false;
|
||||
|
||||
component.validationObserver = new Tracker.Dependency();
|
||||
|
||||
// Reset the pathKey
|
||||
@ -34,6 +37,9 @@ OHIF.mixins.form = new OHIF.Mixin({
|
||||
// Call the original validation function
|
||||
validateSelf();
|
||||
|
||||
// Change the form validated flag to true
|
||||
component.isValidatedAlready = true;
|
||||
|
||||
// Focus the first error field if some validation failed
|
||||
if (component.schema && component.schema._invalidKeys.length) {
|
||||
instance.$('.state-error :input:first').focus();
|
||||
|
||||
@ -235,8 +235,11 @@ OHIF.mixins.formItem = new OHIF.Mixin({
|
||||
// Enable reactivity by changing a Tracker.Dependency observer
|
||||
component.changeObserver.changed();
|
||||
|
||||
// Revalidate the component
|
||||
component.validate();
|
||||
const form = component.getForm();
|
||||
if (form && form.isValidatedAlready) {
|
||||
// Revalidate the component if form is already validated
|
||||
component.validate();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user