mirror of https://github.com/zulip/zulip.git
search: Fix display of suggestion box when search bar empty.
When search bar is empty and we've reached that state by using the `backspace` key. There are no suggestions as there are when you select an empty search bar. The cause of this was an explicit prevention of this suggestion box in `typeahead.js` so that the `backspace` key is free to interact with the other elements. The fix here is to add an optional `hideOnEmpty` option so that if we want this suggestion box to appear we can set this option to `false` and this behavior will be prevented. This option is enabled for the search input when pills are not enabled. Fixes: #25062.
This commit is contained in:
parent
a66c8227d8
commit
0b10a33565
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue