Skip to content

Commit 2607dbb

Browse files
author
ctinney
committed
feat: close dropdown on tab autocompletion
1 parent bce8f85 commit 2607dbb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/autocomplete/typeahead.js

+2
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ _.mixin(Typeahead.prototype, {
287287

288288
_onTabKeyed: function onTabKeyed(type, $e) {
289289
if (!this.tabAutocomplete) {
290+
// Closing the dropdown enables further tabbing
291+
this.dropdown.close();
290292
return;
291293
}
292294

test/unit/typeahead_spec.js

+12
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,18 @@ describe('Typeahead', function() {
495495
expect(this.input.setInputValue).not.toHaveBeenCalledWith(testDatum.value);
496496
expect(spy).not.toHaveBeenCalled();
497497
});
498+
499+
it('should close the dropdown if tabAutocomplete is false', function() {
500+
this.view.tabAutocomplete = false;
501+
502+
this.input.getQuery.and.returnValue('bi');
503+
this.input.getHint.and.returnValue(testDatum.value);
504+
this.input.isCursorAtEnd.and.returnValue(true);
505+
506+
this.input.trigger('tabKeyed');
507+
508+
expect(this.dropdown.close).toHaveBeenCalled();
509+
});
498510
});
499511
});
500512

0 commit comments

Comments
 (0)