composebox_typeahead: Open typeahead immediately when @ is entered.

This change ensures that we pop up the typeahead when one
has entered just `@`. This will make clear to the user
about the @-mentions feature in Zulip.
This also makes us consistent with expectations from other
chatting apps like Slack, Discord, etc.

Added few test cases and modified the present ones.

Fixes: #19142.
This commit is contained in:
akshatdalton
2021-07-07 20:24:48 +00:00
committed by Tim Abbott
parent 572dbafd06
commit 11c37bca8f
2 changed files with 12 additions and 8 deletions

View File

@@ -354,7 +354,7 @@ function filter_mention_name(current_token) {
} else if (current_token.startsWith("*")) {
current_token = current_token.slice(1);
}
if (current_token.length < 1 || current_token.lastIndexOf("*") !== -1) {
if (current_token.lastIndexOf("*") !== -1) {
return false;
}
@@ -648,7 +648,7 @@ export function get_candidates(query) {
current_token = current_token.slice(1);
}
current_token = filter_mention_name(current_token);
if (!current_token) {
if (!current_token && typeof current_token === "boolean") {
this.completing = null;
return false;
}