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: Don't match descriptions for streams and user groups.

N-Shar-ma082e9adcea41
diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.js
index 416ea0d8639..e9db4700231 100644
--- a/frontend_tests/node_tests/composebox_typeahead.js
+++ b/frontend_tests/node_tests/composebox_typeahead.js
@@ -953,7 +953,7 @@ test("initialize", ({override, override_rewire, mock_template}) => {
fake_this.$element.closest = () => [];
fake_this.options = options;
let actual_value = options.source.call(fake_this, "test #s");
- assert.deepEqual(sorted_names_from(actual_value), ["Denmark", "Sweden", "The Netherlands"]);
+ assert.deepEqual(sorted_names_from(actual_value), ["Sweden", "The Netherlands"]);
assert.ok(caret_called);
// options.highlighter()
@@ -1590,15 +1590,15 @@ test("typeahead_results", () => {
assert_mentions_matches("delia lear", []);
assert_mentions_matches("Mark Tw", [twin1, twin2]);
+ // Earlier user group and stream mentions were autocompleted by their
+ // description too. This is now removed as it often led to unexpected
+ // behaviour, and did not have any great discoverability advantage.
+
// Autocomplete user group mentions by group name.
assert_mentions_matches("hamletchar", [hamletcharacters]);
- // Autocomplete user group mentions by group descriptions.
- assert_mentions_matches("characters ", [hamletcharacters]);
- assert_mentions_matches("characters of ", [hamletcharacters]);
- assert_mentions_matches("characters o ", []);
- assert_mentions_matches("haracters of hamlet", []);
- assert_mentions_matches("of hamlet", [hamletcharacters]);
+ // Verify we're not matching on a terms that only appear in the description.
+ assert_mentions_matches("characters of", []);
// Autocomplete by slash commands.
assert_slash_matches("me", [me_slash]);
@@ -1607,14 +1607,15 @@ test("typeahead_results", () => {
assert_slash_matches("light", [light_slash]);
assert_slash_matches("day", [light_slash]);
- // Autocomplete stream by stream name or stream description.
+ // Autocomplete stream by stream name
assert_stream_matches("den", [denmark_stream, sweden_stream]);
assert_stream_matches("denmark", [denmark_stream]);
assert_stream_matches("denmark ", []);
assert_stream_matches("den ", []);
- assert_stream_matches("cold", [sweden_stream, denmark_stream]);
assert_stream_matches("the ", [netherland_stream]);
- assert_stream_matches("city", [netherland_stream]);
+ // Do not match stream descriptions
+ assert_stream_matches("cold", []);
+ assert_stream_matches("city", []);
});
test("message people", ({override}) => {
diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js
index 4ab0c624481..3cf86d1a5a1 100644
--- a/static/js/composebox_typeahead.js
+++ b/static/js/composebox_typeahead.js
@@ -96,13 +96,8 @@ export function query_matches_person(query, person) {
return typeahead.query_matches_source_attrs(query, person, ["full_name", email_attr], " ");
}
-export function query_matches_name_description(query, user_group_or_stream) {
- return typeahead.query_matches_source_attrs(
- query,
- user_group_or_stream,
- ["name", "description"],
- " ",
- );
+export function query_matches_name(query, user_group_or_stream) {
+ return typeahead.query_matches_source_attrs(query, user_group_or_stream, ["name"], " ");
}
function get_stream_or_user_group_matcher(query) {
@@ -110,7 +105,7 @@ function get_stream_or_user_group_matcher(query) {
query = typeahead.clean_query_lowercase(query);
return function (user_group_or_stream) {
- return query_matches_name_description(query, user_group_or_stream);
+ return query_matches_name(query, user_group_or_stream);
};
}
@@ -476,7 +471,7 @@ export function get_person_suggestions(query, opts) {
const groups = user_groups.get_realm_user_groups();
- const filtered_groups = groups.filter((item) => query_matches_name_description(query, item));
+ const filtered_groups = groups.filter((item) => query_matches_name(query, item));
/*
Let's say you're on a big realm and type
diff --git a/static/js/pill_typeahead.js b/static/js/pill_typeahead.js
index 22efe27459e..9f128243572 100644
--- a/static/js/pill_typeahead.js
+++ b/static/js/pill_typeahead.js
@@ -16,7 +16,7 @@ function person_matcher(query, item) {
function group_matcher(query, item) {
if (user_groups.is_user_group(item)) {
- return composebox_typeahead.query_matches_name_description(query, item);
+ return composebox_typeahead.query_matches_name(query, item);
}
return false;
}