diff --git a/web/src/search.js b/web/src/search.js index d6cfc9be52..21f90c006c 100644 --- a/web/src/search.js +++ b/web/src/search.js @@ -93,6 +93,9 @@ export function initialize() { parentElement: "#searchbox_legacy", items: search_suggestion.max_num_of_search_results, helpOnEmptyStrings: true, + // With search pills, the contenteditable input will be empty + // even if some pills are present. + hideOnEmpty: page_params.search_pills_enabled, naturalSearch: true, highlighter(item) { const obj = search_map.get(item); diff --git a/web/third/bootstrap-typeahead/typeahead.js b/web/third/bootstrap-typeahead/typeahead.js index eb5120499d..9c9fcf60eb 100644 --- a/web/third/bootstrap-typeahead/typeahead.js +++ b/web/third/bootstrap-typeahead/typeahead.js @@ -487,8 +487,13 @@ import {get_string_diff} from "../../src/util"; default: var hideOnEmpty = false - if (e.keyCode === 8 && this.options.helpOnEmptyStrings) { // backspace - hideOnEmpty = true + // backspace + if (e.keyCode === 8 && this.options.helpOnEmptyStrings) { + // Support for inputs to set the hideOnEmpty option explicitly to false + // to display typeahead after hitting backspace to clear the input. + if (typeof(this.options.hideOnEmpty) === undefined || this.options.hideOnEmpty) { + hideOnEmpty = true; + } } this.lookup(hideOnEmpty) }