Skip to content

Commit

Permalink
Fixing #9: hitting tab at the end of the search box's last input with…
Browse files Browse the repository at this point in the history
… no text just sends the cursor on its way and no longer loops around to the first input.
  • Loading branch information
samuelclay committed Jan 28, 2013
1 parent aa7e38c commit bcb91db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/js/views/search_box.js
Expand Up @@ -325,8 +325,7 @@ VS.ui.SearchBox = Backbone.View.extend({
} else if (options.skipToFacet && currentView.type == 'text' &&
viewCount == viewPosition && direction >= 0) {
// Special case of looping around to a facet from the last search input box.
viewPosition = 0;
direction = 0;
return false;
}
var view, next = Math.min(viewCount, viewPosition + direction);

Expand Down Expand Up @@ -359,6 +358,8 @@ VS.ui.SearchBox = Backbone.View.extend({
}
if (options.selectText) view.selectText();
this.resizeFacets();

return true;
},

maybeFocusSearch : function(e) {
Expand Down
7 changes: 5 additions & 2 deletions lib/js/views/search_input.js
Expand Up @@ -363,19 +363,22 @@ VS.ui.SearchInput = Backbone.View.extend({
e.preventDefault();
this.app.searchBox.focusNextFacet(this, -1, {selectText: true});
} else if (key == 'tab') {
e.preventDefault();
var value = this.box.val();
if (value.length) {
e.preventDefault();
var remainder = this.addTextFacetRemainder(value);
var position = this.options.position + (remainder?1:0);
if (value != remainder) {
this.app.searchBox.addFacet(value, '', position);
}
} else {
this.app.searchBox.focusNextFacet(this, 0, {
var foundFacet = this.app.searchBox.focusNextFacet(this, 0, {
skipToFacet: true,
selectText: true
});
if (foundFacet) {
e.preventDefault();
}
}
} else if (VS.app.hotkeys.command &&
String.fromCharCode(e.which).toLowerCase() == 'a') {
Expand Down

0 comments on commit bcb91db

Please sign in to comment.