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
1 changed files with 5 additions and 0 deletions

View File

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