Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
shared: Match literal emoji in typeahead.
Austin Ribaa8fd5359556c
diff --git a/frontend_tests/node_tests/typeahead.js b/frontend_tests/node_tests/typeahead.jsindex aa2163279ff..c5525f1bd0c 100644--- a/frontend_tests/node_tests/typeahead.js+++ b/frontend_tests/node_tests/typeahead.js@@ -52,6 +52,8 @@ run_test("get_emoji_matcher", () => {assert_matches("japanese_post_", [emoji_japanese_post_office]);assert_matches("japanese post ", [emoji_japanese_post_office]);++ assert_matches("🐼", [emoji_panda_face]);});run_test("triage", () => {diff --git a/static/shared/js/typeahead.js b/static/shared/js/typeahead.jsindex 361f313882b..b619e3099f2 100644--- a/static/shared/js/typeahead.js+++ b/static/shared/js/typeahead.js@@ -98,13 +98,23 @@ export function clean_query_lowercase(query) {return query;}+export const parse_unicode_emoji_code = (code) =>+ code+ .split("-")+ .map((hex) => String.fromCodePoint(Number.parseInt(hex, 16)))+ .join("");+export function get_emoji_matcher(query) {// replaces spaces with underscores for emoji matchingquery = query.replace(/ /g, "_");query = clean_query_lowercase(query);return function (emoji) {- return query_matches_source_attrs(query, emoji, ["emoji_name"], "_");+ const matches_emoji_literal =+ emoji.emoji_code && parse_unicode_emoji_code(emoji.emoji_code) === query;+ return (+ matches_emoji_literal || query_matches_source_attrs(query, emoji, ["emoji_name"], "_")+ );};}