LT-67: Focusing the first form input on validation error

This commit is contained in:
Bruno Alves de Faria 2016-09-01 08:53:16 -03:00
parent 34a16930ef
commit 620f5fd4ff

View File

@ -35,6 +35,16 @@ OHIF.mixins.form = new OHIF.Mixin({
// Set the component main and style elements
component.$style = component.$element = instance.$('form:first');
instance.autorun(() => {
// Run this computation everytime the validation is triggered
component.validationObserver.depend();
// Focus the first error field if some validation failed
if (component.schema && component.schema._invalidKeys.length) {
instance.$('.state-error :input:first').focus();
}
});
},
events: {