navbar: Update searchbox event listeners behaviour.

These are some UI and UX changes mainly related for when to
display the search pills and when to dispay the narrow description
in the search bar.
This commit is contained in:
Ryan Rehman
2020-05-15 18:14:30 +05:30
committed by Tim Abbott
parent c4e59309e4
commit a7aae94e64
3 changed files with 9 additions and 4 deletions

View File

@@ -12,7 +12,7 @@ const return_true = () => true;
const return_false = () => false;
set_global('$', global.make_zjquery());
set_global('narrow_state', {});
set_global('narrow_state', {filter: return_false});
set_global('search_suggestion', {});
set_global('ui_util', {
change_tab_to: noop,
@@ -283,7 +283,7 @@ run_test('initizalize', () => {
run_test('initiate_search', () => {
let is_searchbox_focused = false;
$('#search_query').focus = () => {
$('#search_arrows').focus = () => {
is_searchbox_focused = true;
};
search.initiate_search();

View File

@@ -177,9 +177,11 @@ exports.initialize = function () {
// while we want to add box-shadow to `#searchbox`. This could have been done
// with `:focus-within` CSS selector, but it is not supported in IE or Opera.
searchbox.on('focusin', function () {
tab_bar.open_search_bar_and_close_narrow_description();
searchbox.css({"box-shadow": "inset 0px 0px 0px 2px hsl(204, 20%, 74%)"});
});
searchbox.on('focusout', function () {
tab_bar.close_search_bar_and_open_narrow_description();
searchbox.css({"box-shadow": "unset"});
});
}

View File

@@ -172,8 +172,11 @@ exports.open_search_bar_and_close_narrow_description = function () {
};
exports.close_search_bar_and_open_narrow_description = function () {
$(".navbar-search").removeClass("expanded");
$("#tab_list").removeClass("hidden");
const filter = narrow_state.filter();
if (!(filter && !filter.is_common_narrow())) {
$(".navbar-search").removeClass("expanded");
$("#tab_list").removeClass("hidden");
}
};
window.tab_bar = exports;