Autofocus on Add File menu (#882)

This commit is contained in:
Nimish Agrawal 2019-03-13 01:47:27 +05:30 committed by Cassie Tarakajian
parent 3527568955
commit 87c012b9f6

View file

@ -8,6 +8,10 @@ class NewFileForm extends React.Component {
this.createFile = this.props.createFile.bind(this); this.createFile = this.props.createFile.bind(this);
} }
componentDidMount() {
this.fileName.focus();
}
render() { render() {
const { fields: { name }, handleSubmit } = this.props; const { fields: { name }, handleSubmit } = this.props;
return ( return (
@ -25,6 +29,7 @@ class NewFileForm extends React.Component {
type="text" type="text"
placeholder="Name" placeholder="Name"
{...domOnlyProps(name)} {...domOnlyProps(name)}
ref={(element) => { this.fileName = element; }}
/> />
<input type="submit" value="Add File" aria-label="add file" /> <input type="submit" value="Add File" aria-label="add file" />
{name.touched && name.error && <span className="form-error">{name.error}</span>} {name.touched && name.error && <span className="form-error">{name.error}</span>}