Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
When the files element receives focus just expand the advanced panel.
  • Loading branch information
kellegous committed Mar 15, 2015
1 parent 3eeb57d commit 24ca708
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ui/assets/js/hound.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ var SearchBar = React.createClass({
queryGotKeydown: function(event) {
switch (event.keyCode) {
case 40:
this.showAdvanced();
// this will cause advanced to expand if it is not expanded.
this.refs.files.getDOMNode().focus();
break;
case 38:
this.hideAdvanced();
Expand All @@ -337,6 +338,11 @@ var SearchBar = React.createClass({
break;
}
},
queryGotFocus: function(event) {
if (!this.hasAdvancedValues()) {
this.hideAdvanced();
}
},
filesGotKeydown: function(event) {
switch (event.keyCode) {
case 38:
Expand All @@ -351,6 +357,9 @@ var SearchBar = React.createClass({
break;
}
},
filesGotFocus: function(event) {
this.showAdvanced();
},
submitQuery: function() {
this.props.onSearchRequested(this.getParams());
},
Expand Down Expand Up @@ -441,7 +450,8 @@ var SearchBar = React.createClass({
placeholder="Search by Regexp"
ref="q"
autocomplete="off"
onKeyDown={this.queryGotKeydown} />
onKeyDown={this.queryGotKeydown}
onFocus={this.queryGotFocus}/>
<div className="button-add-on">
<button id="dodat" onClick={this.submitQuery}></button>
</div>
Expand All @@ -457,7 +467,8 @@ var SearchBar = React.createClass({
id="files"
placeholder="/regexp/"
ref="files"
onKeyDown={this.filesGotKeydown} />
onKeyDown={this.filesGotKeydown}
onFocus={this.filesGotFocus} />
</div>
</div>
<div className="field">
Expand Down

0 comments on commit 24ca708

Please sign in to comment.