Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
search: Avoid topic suggestions for channel term with empty operand.
apoorvapendsee502df4c574f
diff --git a/web/src/search_suggestion.ts b/web/src/search_suggestion.tsindex 70a2ccb38c5..295c5d3b8ff 100644--- a/web/src/search_suggestion.ts+++ b/web/src/search_suggestion.ts@@ -569,6 +569,12 @@ function get_topic_suggestions(return [];}+ // Avoid sending topic suggestions when the user is+ // just trying to search through channels.+ if (channel_id_or_operand_str?.length === 0 && last.operator === "channel") {+ return [];+ }+// We don't want to show topic suggestions from negated channelsconst excluded_channel_ids = new Set(termsdiff --git a/web/tests/search_suggestion.test.cjs b/web/tests/search_suggestion.test.cjsindex 35d1e21aee2..b2e51ee4362 100644--- a/web/tests/search_suggestion.test.cjs+++ b/web/tests/search_suggestion.test.cjs@@ -834,6 +834,13 @@ test("topic_suggestions", ({override, override_rewire}) => {suggestions = get_suggestions("hello channel:foobar");expected = [];assert.deepEqual(suggestions, expected);++ // We shouldn't see topic suggestions for an+ // empty operand with channel as the operator for+ // the last term.+ suggestions = get_suggestions("hello channel:");+ expected = ["hello channel:5", "hello channel:6"];+ assert.deepEqual(suggestions, expected);});test("topic_suggestions (limits)", () => {