mirror of https://github.com/zulip/zulip.git
search: Open typeahead on initiating search.
This fixes a bug where the hotkeys used to search messages doesn't work for pills enabled case.
This commit is contained in:
parent
42f1cb3444
commit
aeb4419d52
|
@ -282,10 +282,30 @@ run_test('initizalize', () => {
|
|||
});
|
||||
|
||||
run_test('initiate_search', () => {
|
||||
// open typeahead and select text when navbar is open
|
||||
// this implicitly expects the code to used the chained
|
||||
// function calls, which is something to keep in mind if
|
||||
// this test ever fails unexpectedly.
|
||||
let typeahead_forced_open = false;
|
||||
let is_searchbox_text_selected = false;
|
||||
let is_searchbox_focused = false;
|
||||
$('#search_arrows').focus = () => {
|
||||
$('#search_query').focus = () => {
|
||||
is_searchbox_focused = true;
|
||||
};
|
||||
$('#search_query').select = noop;
|
||||
$('#search_query').typeahead = (lookup) => {
|
||||
if (lookup === "lookup") {
|
||||
typeahead_forced_open = true;
|
||||
return {
|
||||
select: () => {
|
||||
is_searchbox_text_selected = true;
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
search.initiate_search();
|
||||
assert(typeahead_forced_open);
|
||||
assert(is_searchbox_text_selected);
|
||||
assert(is_searchbox_focused);
|
||||
});
|
||||
|
|
|
@ -193,11 +193,10 @@ exports.focus_search = function () {
|
|||
};
|
||||
|
||||
exports.initiate_search = function () {
|
||||
tab_bar.open_search_bar_and_close_narrow_description();
|
||||
$('#search_query').typeahead('lookup').select();
|
||||
if (page_params.search_pills_enabled) {
|
||||
$('#search_arrows').focus();
|
||||
} else {
|
||||
tab_bar.open_search_bar_and_close_narrow_description();
|
||||
$('#search_query').typeahead('lookup').select();
|
||||
$('#search_query').focus();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue