Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
search_suggestion: Fix empty topic suggestion topic display name.
Pratik Chanda62093ee37d61
diff --git a/web/src/search_pill.ts b/web/src/search_pill.tsindex 34778759269..7640768a441 100644--- a/web/src/search_pill.ts+++ b/web/src/search_pill.ts@@ -121,7 +121,7 @@ function on_pill_exit(// pill. We can probably simplify things by separating out a function// that generates `description_html` from the information in a single// search pill, and remove `description_html` from the `Suggestion` type.-export function generate_pills_html(suggestion: Suggestion, query: string): string {+export function generate_pills_html(suggestion: Suggestion, text_query: string): string {const search_terms = Filter.parse(suggestion.search_string);const pill_render_data = search_terms.map((term, index) => {@@ -136,21 +136,28 @@ export function generate_pills_html(suggestion: Suggestion, query: string): stri};if (search_pill.operator === "topic" && search_pill.operand === "") {- // There are two variants of this suggestion state: One is the user- // has selected a topic operator and operator, and and thus has- // exactly `topic:` or `-topic:` written out, and it's be- // appropriate to suggest the "general chat" value.+ // There are three variants of this suggestion state://- // The other variant is where we're suggesting `topic` as a- // potential operator to add, say if the user has typed `-to` so- // far. For that case, we want to suggest adding a topic operator,- // but the user hasn't done anything that would suggest we should- // further complete "general chat" as value for that topic operator.+ // (1) This is an already formed pill, i.e. not in the text input+ // (`text_query`), or is not the last term in the text input, and+ // therefore the empty operand represents "general chat".//- // We can simply differentiate these cases by checking if `:` is- // present in the query. See `set_search_bar_contents` for more- // context.- if (query.includes(":")) {+ // (2) The user has selected a topic operator, and and thus has+ // exactly `topic:` or `-topic:` written out, and it's appropriate+ // to suggest the "general chat" operand.+ //+ // (3) We're suggesting `topic` as a potential operator to add, say+ // if the user has typed `-to` so far. For that case, we want to+ // suggest adding a topic operator, but the user hasn't done anything+ // that would suggest we should further complete "general chat" as an+ // operand for that topic operator.+ if (+ // case 1+ text_query === "" ||+ index < search_terms.length - 1 ||+ // case 2+ text_query.trim().endsWith("topic:")+ ) {return {...search_pill,is_empty_string_topic: true,@@ -158,6 +165,7 @@ export function generate_pills_html(suggestion: Suggestion, query: string): stritopic_display_name: util.get_final_topic_display_name(""),};}+ // case 3return {...search_pill,is_empty_string_topic: true,