diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index e3256bbd..76beaf3e 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -51,8 +51,7 @@ var Typeahead = (function() { .onSync('queryChanged', this._onQueryChanged, this) .onSync('whitespaceChanged', this._onWhitespaceChanged, this); - // HACK: prevents input blur on menu click - // https://github.com/twitter/typeahead.js/pull/351 + // #351: prevents input blur on menu click $menu.on('mousedown.tt', function($e) { if (_.isMsie() && _.isMsie() < 9) { $input[0].onbeforedeactivate = function() { @@ -242,14 +241,13 @@ var Typeahead = (function() { this.input.clearHint(); this.input.setQuery(datum.value); this.input.setInputValue(datum.value, true); - this.dropdown.empty(); + this.dropdown.close(); this._setLanguageDirection(); - // in ie, focus is not a synchronous event, so when a selection - // is triggered by a click within the dropdown menu, we need to - // defer the closing of the dropdown otherwise it'll stay open - _.defer(_.bind(this.dropdown.close, this.dropdown)); + // #118: allow click event to bubble up to the body before removing + // the suggestions otherwise we break event delegation + _.defer(_.bind(this.dropdown.empty, this.dropdown)); this.eventBus.trigger('selected', datum.raw, datum.datasetName); },