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: Do not prioritize exact name matches for users.

Tim Abbott18e2cee572ef
diff --git a/web/src/typeahead_helper.js b/web/src/typeahead_helper.js
index 8a8f38f7084..b6fde756b52 100644
--- a/web/src/typeahead_helper.js
+++ b/web/src/typeahead_helper.js
@@ -387,21 +387,12 @@ export function sort_recipients({
}
}
- // Push exact matches to top. We could do by passing the
- // comparator parameter to triage, but that would break the
- // optimization of only doing expensive sorting operations when
- // necessary.
- const exact_matches = [];
- const rest = [];
- for (const item of items) {
- if (item.full_name?.toLowerCase() === query.toLowerCase()) {
- exact_matches.push(item);
- } else {
- rest.push(item);
- }
- }
-
- return [...exact_matches, ...rest].slice(0, max_num_items);
+ // We don't push exact matches to the top, like we do with other
+ // typeaheads, because in open organizations, it's not uncommon to
+ // have a bunch of inactive users with display names that are just
+ // FirstName, which we don't want to artificially prioritize over the
+ // the lone active user whose name is FirstName LastName.
+ return items.slice(0, max_num_items);
}
function slash_command_comparator(slash_command_a, slash_command_b) {
diff --git a/web/tests/composebox_typeahead.test.js b/web/tests/composebox_typeahead.test.js
index 7f58063583d..5c905f637e0 100644
--- a/web/tests/composebox_typeahead.test.js
+++ b/web/tests/composebox_typeahead.test.js
@@ -1784,8 +1784,8 @@ test("PM recipients sorted according to stream / topic being viewed", ({override
(stream_id, user_id) => stream_id === denmark_stream.stream_id && user_id === alice.user_id,
);
- // When viewing denmark stream to which alice is subscribed, ali is still
- // 1st by virtue of the name being an exact match with the query.
+ // When viewing denmark stream to which alice is subscribed, ali is not
+ // 1st despite having an exact name match with the query.
results = ct.get_pm_people("ali");
- assert.deepEqual(results, [ali, alice]);
+ assert.deepEqual(results, [alice, ali]);
});