Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

typeahead: Fix '@topic' not present when stream wildcard suggested.

Prakhar Pratyushc76b3acce7e2
diff --git a/web/src/typeahead_helper.js b/web/src/typeahead_helper.js
index 12736cfb656..257859d2085 100644
--- a/web/src/typeahead_helper.js
+++ b/web/src/typeahead_helper.js
@@ -398,15 +398,16 @@ export function sort_recipients({
}
}
- // We suggest only the first matching wildcard mention,
- // irrespective of how many equivalent wildcard mentions match.
+ // We suggest only the first matching stream wildcard mention,
+ // irrespective of how many equivalent stream wildcard mentions match.
const recipients = [];
- let wildcard_mention_included = false;
+ let stream_wildcard_mention_included = false;
for (const item of items) {
- if (!item.is_broadcast || !wildcard_mention_included) {
+ const topic_wildcard_mention = item.email === "topic";
+ if (!item.is_broadcast || topic_wildcard_mention || !stream_wildcard_mention_included) {
recipients.push(item);
- if (item.is_broadcast) {
- wildcard_mention_included = true;
+ if (item.is_broadcast && !topic_wildcard_mention) {
+ stream_wildcard_mention_included = true;
}
}
}
diff --git a/web/tests/composebox_typeahead.test.js b/web/tests/composebox_typeahead.test.js
index 6db9673a96d..3b1bd54b43d 100644
--- a/web/tests/composebox_typeahead.test.js
+++ b/web/tests/composebox_typeahead.test.js
@@ -1753,8 +1753,8 @@ test("typeahead_results", () => {
// Verify we're not matching on a terms that only appear in the description.
assert_mentions_matches("characters of", []);
- // Verify we suggest only the first matching wildcard mention,
- // irrespective of how many equivalent wildcard mentions match.
+ // Verify we suggest only the first matching stream wildcard mention,
+ // irrespective of how many equivalent stream wildcard mentions match.
const mention_everyone = ct.broadcast_mentions()[1];
// Here, we suggest only "everyone" instead of both the matching
// "everyone" and "stream" wildcard mentions.
@@ -1771,6 +1771,12 @@ test("typeahead_results", () => {
call_center,
]);
+ // Verify we suggest both 'the first matching stream wildcard' and
+ // 'topic wildcard' mentions. Not only one matching wildcard mention.
+ const mention_topic = ct.broadcast_mentions()[3];
+ // Here, we suggest both "everyone" and "topic".
+ assert_mentions_matches("o", [othello, mention_everyone, mention_topic, cordelia]);
+
// Autocomplete by slash commands.
assert_slash_matches("me", [me_slash]);
assert_slash_matches("dark", [dark_slash]);