mirror of
https://github.com/zhigang1992/typeahead.js.git
synced 2026-04-29 01:34:55 +08:00
Change behavior of autocomplete. Closes #49.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user