1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

[CE] search: added auto focus for the input (#4809)

This commit is contained in:
llj
2021-02-01 20:57:32 +08:00
committed by GitHub
parent a79d9327cb
commit 1cb10e4dd5

View File

@@ -23,6 +23,11 @@ class SearchFileDialog extends React.Component {
errMessage: '',
fileList: null
};
this.inputRef = React.createRef();
}
componentDidMount() {
this.inputRef.current.focus();
}
searchFile = () => {
@@ -77,7 +82,7 @@ class SearchFileDialog extends React.Component {
<ModalHeader toggle={this.toggle}>{gettext('Search')}</ModalHeader>
<ModalBody style={{height: '250px'}} className="o-auto">
<div className="d-flex">
<input className="form-control mr-2" type="text" placeholder={gettext('Search files in this library')} value={q} onChange={this.handleInputChange} onKeyDown={this.handleKeyDown} />
<input className="form-control mr-2" type="text" placeholder={gettext('Search files in this library')} value={q} onChange={this.handleInputChange} onKeyDown={this.handleKeyDown} ref={this.inputRef} />
<button type="submit" className={`btn btn-primary flex-shrink-0 ${isSubmitting ? 'btn-loading' : ''}`} onClick={this.searchFile} disabled={isSubmitDisabled}>{gettext('Search')}</button>
</div>
{errMessage && <Alert color="danger" className="mt-2">{errMessage}</Alert>}