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:
parent
62a01e7a37
commit
5d95c31875
2 changed files with 60 additions and 21 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue