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.

composebox_topic_typeahead: Add support for empty string topic.

Prakhar Pratyush9a29320d6121
diff --git a/web/src/composebox_typeahead.ts b/web/src/composebox_typeahead.ts
index 035ca8c3fa7..6bc5e5d67a6 100644
--- a/web/src/composebox_typeahead.ts
+++ b/web/src/composebox_typeahead.ts
@@ -1456,7 +1456,12 @@ export function initialize({
},
items: max_num_items,
highlighter_html(item: string): string {
- return typeahead_helper.render_typeahead_item({primary: item});
+ const is_empty_string_topic = item === "";
+ const topic_display_name = util.get_final_topic_display_name(item);
+ return typeahead_helper.render_typeahead_item({
+ primary: topic_display_name,
+ is_empty_string_topic,
+ });
},
sorter(items: string[], query: string): string[] {
const sorted = typeahead_helper.sorter(query, items, (x) => x);
@@ -1466,7 +1471,7 @@ export function initialize({
return sorted;
},
option_label(matching_items: string[], item: string): string | false {
- if (!matching_items.includes(item)) {
+ if (item !== "" && !matching_items.includes(item)) {
return `<em>${$t({defaultMessage: "New"})}</em>`;
}
return false;
diff --git a/web/src/typeahead_helper.ts b/web/src/typeahead_helper.ts
index 2161b05378c..909a511cd79 100644
--- a/web/src/typeahead_helper.ts
+++ b/web/src/typeahead_helper.ts
@@ -111,6 +111,7 @@ export let render_typeahead_item = (args: {
emoji_code?: string | undefined;
topic_object?: TopicSuggestion;
is_stream_topic?: boolean;
+ is_empty_string_topic?: boolean;
}): string => {
const has_image = args.img_src !== undefined;
const has_status = args.status_emoji_info !== undefined;
diff --git a/web/templates/typeahead_list_item.hbs b/web/templates/typeahead_list_item.hbs
index 80204612ef2..eba7f4bf975 100644
--- a/web/templates/typeahead_list_item.hbs
+++ b/web/templates/typeahead_list_item.hbs
@@ -31,7 +31,7 @@
{{else}}
{{!-- Separate container to ensure overflowing text remains in this container. --}}
<div class="typeahead-text-container{{#if has_secondary_html}} has_secondary_html{{/if}}">
- <strong class="typeahead-strong-section">
+ <strong class="typeahead-strong-section{{#if is_empty_string_topic}} empty-topic-display{{/if}}">
{{~#if stream~}}
{{~> inline_decorated_stream_name stream=stream ~}}
{{~else~}}