diff --git a/static/js/narrow.js b/static/js/narrow.js index 45da068d8a..2962aeaa8a 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -311,7 +311,11 @@ exports.activate = function (raw_operators, opts) { } // Put the narrow operators in the search bar. - $('#search_query').val(Filter.unparse(operators)); + // we append a space to make searching more convenient in some cases. + if (filter && !filter.is_search()) { + $('#search_query').val(Filter.unparse(operators) + " "); + } + search.update_button_visibility(); compose_actions.on_narrow(opts); diff --git a/static/js/tab_bar.js b/static/js/tab_bar.js index 4c9989aabb..fa8d4f003b 100644 --- a/static/js/tab_bar.js +++ b/static/js/tab_bar.js @@ -87,7 +87,12 @@ exports.exit_search = function () { // reset searchbox text const search_string = narrow_state.search_string(); - $("#search_query").val(search_string); + // This does not need to be conditional like the corresponding + // function call in narrow.activate because search filters are + // not common narrows + if (search_string !== "") { + $("#search_query").val(search_string + " "); + } } else { // for "searching narrows", we redirect window.location.replace(filter.generate_redirect_url());