Focus the first invalid field
This adjusts the submission step to focus the first invalid field and redisplay validation. This also rearranges the older style field error handling on registration which is slated for removal once we convert all fields to the new style.
This commit is contained in:
@@ -86,6 +86,10 @@ export default class Field extends React.PureComponent {
|
||||
}
|
||||
};
|
||||
|
||||
focus() {
|
||||
this.input.focus();
|
||||
}
|
||||
|
||||
validate({ value, focused }) {
|
||||
if (!this.props.onValidate) {
|
||||
return;
|
||||
@@ -107,6 +111,7 @@ export default class Field extends React.PureComponent {
|
||||
|
||||
// Set some defaults for the <input> element
|
||||
inputProps.type = inputProps.type || "text";
|
||||
inputProps.ref = input => this.input = input;
|
||||
inputProps.placeholder = inputProps.placeholder || inputProps.label;
|
||||
|
||||
inputProps.onFocus = this.onFocus;
|
||||
|
||||
Reference in New Issue
Block a user