mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
search: Bold search operands in the first search result.
Specifically when it's the last operand of the search filter. This makes the first line of search results more consistent with the lines that come after.
This commit is contained in:
@@ -749,7 +749,16 @@ export function get_search_result(query) {
|
||||
// `has` and `is` operators work only on predefined categories. Default suggestion
|
||||
// is not displayed in that case. e.g. `messages that contain abc` as
|
||||
// a suggestion for `has:abc`does not make sense.
|
||||
if (last.operator !== "" && last.operator !== "has" && last.operator !== "is") {
|
||||
if (last.operator === "search") {
|
||||
suggestion = {
|
||||
search_string: last.operand,
|
||||
description_html: `search for <strong>${Handlebars.Utils.escapeExpression(
|
||||
last.operand,
|
||||
)}</strong>`,
|
||||
};
|
||||
attacher.prepend_base(suggestion);
|
||||
attacher.push(suggestion);
|
||||
} else if (last.operator !== "" && last.operator !== "has" && last.operator !== "is") {
|
||||
suggestion = get_default_suggestion(search_operators);
|
||||
attacher.push(suggestion);
|
||||
}
|
||||
|
||||
@@ -79,9 +79,7 @@ function test(label, f) {
|
||||
});
|
||||
}
|
||||
|
||||
test("basic_get_suggestions", ({override, mock_template}) => {
|
||||
mock_template("search_description.hbs", true, (data, html) => html);
|
||||
|
||||
test("basic_get_suggestions", ({override}) => {
|
||||
const query = "fred";
|
||||
|
||||
override(narrow_state, "stream", () => "office");
|
||||
@@ -717,7 +715,7 @@ test("topic_suggestions", ({override, mock_template}) => {
|
||||
function describe(q) {
|
||||
return suggestions.lookup_table.get(q).description_html;
|
||||
}
|
||||
assert.equal(describe("te"), "Search for te");
|
||||
assert.equal(describe("te"), "Search for <strong>te</strong>");
|
||||
assert.equal(describe("stream:office topic:team"), "Stream office > team");
|
||||
|
||||
suggestions = get_suggestions("topic:staplers stream:office");
|
||||
|
||||
Reference in New Issue
Block a user