Change behavior of autocomplete. Closes #49.

This commit is contained in:
Jake Harding
2013-03-13 00:00:00 -07:00
parent d425204ffc
commit 56354bb4d0
2 changed files with 6 additions and 2 deletions

View File

@@ -239,7 +239,7 @@ var TypeaheadView = (function() {
},
_autocomplete: function(e) {
var isCursorAtEnd, ignoreEvent, query, hint;
var isCursorAtEnd, ignoreEvent, query, hint, suggestion;
if (e.type === 'rightKeyed' || e.type === 'leftKeyed') {
isCursorAtEnd = this.inputView.isCursorAtEnd();
@@ -253,7 +253,8 @@ var TypeaheadView = (function() {
hint = this.inputView.getHintValue();
if (hint !== '' && query !== hint) {
this.inputView.setInputValue(hint);
suggestion = this.dropdownView.getFirstSuggestion();
this.inputView.setInputValue(suggestion.value);
}
},

View File

@@ -361,6 +361,7 @@ describe('TypeaheadView', function() {
beforeEach(function() {
this.inputView.getQuery.andReturn('app');
this.inputView.getHintValue.andReturn('apple');
this.dropdownView.getFirstSuggestion.andReturn({ value: 'apple' });
this.inputView.trigger('tabKeyed', this.$e);
});
@@ -379,6 +380,7 @@ describe('TypeaheadView', function() {
beforeEach(function() {
this.inputView.getQuery.andReturn('app');
this.inputView.getHintValue.andReturn('apple');
this.dropdownView.getFirstSuggestion.andReturn({ value: 'apple' });
this.inputView.isCursorAtEnd.andReturn(true);
this.inputView.getLanguageDirection.andReturn('ltr');
});
@@ -424,6 +426,7 @@ describe('TypeaheadView', function() {
beforeEach(function() {
this.inputView.getQuery.andReturn('app');
this.inputView.getHintValue.andReturn('apple');
this.dropdownView.getFirstSuggestion.andReturn({ value: 'apple' });
this.inputView.isCursorAtEnd.andReturn(true);
this.inputView.getLanguageDirection.andReturn('ltr');
});