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: Re render header html for every update in user string.

roanster007b61fb243f7a3
diff --git a/web/src/bootstrap_typeahead.ts b/web/src/bootstrap_typeahead.ts
index 07e621e77f8..242c87f03e8 100644
--- a/web/src/bootstrap_typeahead.ts
+++ b/web/src/bootstrap_typeahead.ts
@@ -373,14 +373,6 @@ export class Typeahead<ItemType extends string | object> {
// Call this early to avoid duplicate calls.
this.shown = true;
-
- const header_text_html = this.header_html();
- if (header_text_html) {
- this.$header.find("span#typeahead-header-text").html(header_text_html);
- this.$header.show();
- } else {
- this.$header.hide();
- }
this.mouse_moved_since_typeahead = false;
const input_element = this.input_element;
@@ -564,6 +556,19 @@ export class Typeahead<ItemType extends string | object> {
return $i;
});
+ // We want to re render the typeahead header for ever update
+ // in user's string since once typeahead is shown after `@`,
+ // header might change depending on whether next character is
+ // `_` (silent mention) or not.
+ const header_text_html = this.header_html();
+
+ if (header_text_html) {
+ this.$header.find("span#typeahead-header-text").html(header_text_html);
+ this.$header.show();
+ } else {
+ this.$header.hide();
+ }
+
if (this.requireHighlight || this.shouldHighlightFirstResult()) {
$items[0]!.addClass("active");
}