Search queries when enter is pressed (#6043)

* Search queries when enter is pressed

* Add unit test

* Remove line

* Improve test
This commit is contained in:
Beto Dealmeida
2018-10-07 12:48:06 -07:00
committed by GitHub
parent 06e029f9d3
commit 96952d0daf
2 changed files with 18 additions and 4 deletions

View File

@@ -41,6 +41,7 @@ class QuerySearch extends React.PureComponent {
this.dbMutator = this.dbMutator.bind(this);
this.onChange = this.onChange.bind(this);
this.changeSearch = this.changeSearch.bind(this);
this.onKeyDown = this.onKeyDown.bind(this);
this.changeFrom = this.changeFrom.bind(this);
this.changeTo = this.changeTo.bind(this);
this.changeStatus = this.changeStatus.bind(this);
@@ -65,6 +66,11 @@ class QuerySearch extends React.PureComponent {
const val = db ? db.value : null;
this.setState({ databaseId: val });
}
onKeyDown(event) {
if (event.keyCode === 13) {
this.refreshQueries();
}
}
getTimeFromSelection(selection) {
switch (selection) {
case 'now':
@@ -173,6 +179,7 @@ class QuerySearch extends React.PureComponent {
<input
type="text"
onChange={this.changeSearch}
onKeyDown={this.onKeyDown}
className="form-control input-sm"
placeholder={t('Search Results')}
/>