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.

template: Wrap typeahead list item inside typeahead-content class.

Pratik Chanda36ccd6a595c2
diff --git a/web/styles/typeahead.css b/web/styles/typeahead.css
index d5de475c4c5..58cd1e6191b 100644
--- a/web/styles/typeahead.css
+++ b/web/styles/typeahead.css
@@ -67,6 +67,13 @@
}
}
+ .typeahead-content {
+ display: flex;
+ align-items: center;
+ overflow: hidden;
+ gap: 0.3571em;
+ }
+
.typeahead-text-container {
display: flex;
align-self: center;
diff --git a/web/templates/typeahead_list_item.hbs b/web/templates/typeahead_list_item.hbs
index 07408b653fb..70bcbea5994 100644
--- a/web/templates/typeahead_list_item.hbs
+++ b/web/templates/typeahead_list_item.hbs
@@ -1,58 +1,60 @@
-{{#if is_emoji}}
- {{#if has_image}}
- <img class="emoji" src="{{ img_src }}" />
- {{else}}
- <span class='emoji emoji-{{ emoji_code }}'></span>
- {{/if}}
-{{else if is_person}}
- {{#if has_image}}
- <div class="typeahead-image">
- <img class="typeahead-image-avatar" src="{{ img_src }}" />
- {{#if user_circle_class}}
- <span class="zulip-icon zulip-icon-{{user_circle_class}} {{user_circle_class}} user-circle"></span>
+<div class="typeahead-content">
+ {{#if is_emoji}}
+ {{#if has_image}}
+ <img class="emoji" src="{{ img_src }}" />
+ {{else}}
+ <span class='emoji emoji-{{ emoji_code }}'></span>
{{/if}}
+ {{else if is_person}}
+ {{#if has_image}}
+ <div class="typeahead-image">
+ <img class="typeahead-image-avatar" src="{{ img_src }}" />
+ {{#if user_circle_class}}
+ <span class="zulip-icon zulip-icon-{{user_circle_class}} {{user_circle_class}} user-circle"></span>
+ {{/if}}
+ </div>
+ {{else}}
+ <i class='typeahead-image zulip-icon zulip-icon-user-group' aria-hidden="true"></i>
+ {{/if}}
+ {{else if is_user_group}}
+ <i class="typeahead-image zulip-icon zulip-icon-user-group" aria-hidden="true"></i>
+ {{/if}}
+ {{#if is_stream_topic}}
+ <div class="typeahead-text-container">
+ <span role="button" class="zulip-icon zulip-icon-corner-down-right stream-to-topic-arrow"></span>
+ <strong class="typeahead-strong-section{{#if is_empty_string_topic}} empty-topic-display{{/if}}">
+ {{~ topic_display_name ~}}
+ </strong>
</div>
{{else}}
- <i class='typeahead-image zulip-icon zulip-icon-user-group' aria-hidden="true"></i>
- {{/if}}
-{{else if is_user_group}}
- <i class="typeahead-image zulip-icon zulip-icon-user-group" aria-hidden="true"></i>
-{{/if}}
-{{#if is_stream_topic}}
-<div class="typeahead-text-container">
- <span role="button" class="zulip-icon zulip-icon-corner-down-right stream-to-topic-arrow"></span>
- <strong class="typeahead-strong-section{{#if is_empty_string_topic}} empty-topic-display{{/if}}">
- {{~ topic_display_name ~}}
- </strong>
-</div>
-{{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{{#if is_empty_string_topic}} empty-topic-display{{/if}}{{#if is_default_language}} default-language-display{{/if}}">
- {{~#if stream~}}
- {{~> inline_decorated_channel_name stream=stream ~}}
- {{~else~}}
- {{~ primary ~}}
- {{~/if~}}
- </strong>
- {{~#if is_bot}}
- <i class="zulip-icon zulip-icon-bot" aria-label="{{t 'Bot' }}"></i>
+ {{!-- 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{{#if is_empty_string_topic}} empty-topic-display{{/if}}{{#if is_default_language}} default-language-display{{/if}}">
+ {{~#if stream~}}
+ {{~> inline_decorated_channel_name stream=stream ~}}
+ {{~else~}}
+ {{~ primary ~}}
+ {{~/if~}}
+ </strong>
+ {{~#if is_bot}}
+ <i class="zulip-icon zulip-icon-bot" aria-label="{{t 'Bot' }}"></i>
+ {{/if}}
+ {{~#if should_add_guest_user_indicator}}
+ <i>({{t 'guest'}})</i>
+ {{~/if}}
+ {{~#if has_status}}
+ {{> status_emoji status_emoji_info}}
+ {{~/if}}
+ {{~#if has_pronouns}}
+ <span class="pronouns">{{pronouns}}{{#if (or has_secondary_html has_secondary)}},{{/if}}</span>
+ {{~/if}}
+ {{~#if has_secondary_html}}
+ <span class="autocomplete_secondary rendered_markdown single-line-rendered-markdown">{{rendered_markdown secondary_html}}</span>
+ {{~else if has_secondary}}
+ <span class="autocomplete_secondary">
+ {{~ secondary ~}}
+ </span>
+ {{~/if}}
+ </div>
{{/if}}
- {{~#if should_add_guest_user_indicator}}
- <i>({{t 'guest'}})</i>
- {{~/if}}
- {{~#if has_status}}
- {{> status_emoji status_emoji_info}}
- {{~/if}}
- {{~#if has_pronouns}}
- <span class="pronouns">{{pronouns}}{{#if (or has_secondary_html has_secondary)}},{{/if}}</span>
- {{~/if}}
- {{~#if has_secondary_html}}
- <span class="autocomplete_secondary rendered_markdown single-line-rendered-markdown">{{rendered_markdown secondary_html}}</span>
- {{~else if has_secondary}}
- <span class="autocomplete_secondary">
- {{~ secondary ~}}
- </span>
- {{~/if}}
</div>
-{{/if}}
diff --git a/web/tests/composebox_typeahead.test.cjs b/web/tests/composebox_typeahead.test.cjs
index 4678719f0a7..82dc5038b4a 100644
--- a/web/tests/composebox_typeahead.test.cjs
+++ b/web/tests/composebox_typeahead.test.cjs
@@ -1231,23 +1231,29 @@ test("initialize", ({override, override_rewire, mock_template}) => {
options.query = "Kro";
actual_value = options.item_html("kronor");
expected_value =
- '<div class="typeahead-text-container">\n' +
- ' <strong class="typeahead-strong-section">kronor</strong></div>\n';
+ '<div class="typeahead-content">\n' +
+ ' <div class="typeahead-text-container">\n' +
+ ' <strong class="typeahead-strong-section">kronor</strong> </div>\n' +
+ "</div>\n";
assert.equal(actual_value, expected_value);
// Highlighted content should be escaped.
options.query = "<";
actual_value = options.item_html("<&>");
expected_value =
- '<div class="typeahead-text-container">\n' +
- ' <strong class="typeahead-strong-section">&lt;&amp;&gt;</strong></div>\n';
+ '<div class="typeahead-content">\n' +
+ ' <div class="typeahead-text-container">\n' +
+ ' <strong class="typeahead-strong-section">&lt;&amp;&gt;</strong> </div>\n' +
+ "</div>\n";
assert.equal(actual_value, expected_value);
options.query = "even m";
actual_value = options.item_html("even more ice");
expected_value =
- '<div class="typeahead-text-container">\n' +
- ' <strong class="typeahead-strong-section">even more ice</strong></div>\n';
+ '<div class="typeahead-content">\n' +
+ ' <div class="typeahead-text-container">\n' +
+ ' <strong class="typeahead-strong-section">even more ice</strong> </div>\n' +
+ "</div>\n";
assert.equal(actual_value, expected_value);
// options.sorter()
@@ -1479,12 +1485,14 @@ test("initialize", ({override, override_rewire, mock_template}) => {
ct.get_or_set_token_for_testing("othello");
actual_value = options.item_html(othello_item);
expected_value =
- ' <div class="typeahead-image">\n' +
- ` <img class="typeahead-image-avatar" src="/avatar/${othello.user_id}" />\n` +
- ' <span class="zulip-icon zulip-icon-user-circle-offline user-circle-offline user-circle"></span>\n' +
+ '<div class="typeahead-content">\n' +
+ ' <div class="typeahead-image">\n' +
+ ` <img class="typeahead-image-avatar" src="/avatar/${othello.user_id}" />\n` +
+ ' <span class="zulip-icon zulip-icon-user-circle-offline user-circle-offline user-circle"></span>\n' +
+ " </div>\n" +
+ ' <div class="typeahead-text-container">\n' +
+ ' <strong class="typeahead-strong-section">Othello, the Moor of Venice</strong> <span class="autocomplete_secondary">[email protected]</span>' +
" </div>\n" +
- '<div class="typeahead-text-container">\n' +
- ' <strong class="typeahead-strong-section">Othello, the Moor of Venice</strong> <span class="autocomplete_secondary">[email protected]</span>' +
"</div>\n";
assert.equal(actual_value, expected_value);
// Reset the email such that this does not affect further tests.
@@ -1494,9 +1502,11 @@ test("initialize", ({override, override_rewire, mock_template}) => {
ct.get_or_set_token_for_testing("hamletcharacters");
actual_value = options.item_html(hamletcharacters);
expected_value =
- ' <i class="typeahead-image zulip-icon zulip-icon-user-group" aria-hidden="true"></i>\n' +
- '<div class="typeahead-text-container">\n' +
- ' <strong class="typeahead-strong-section">hamletcharacters</strong> <span class="autocomplete_secondary">Characters of Hamlet</span>' +
+ '<div class="typeahead-content">\n' +
+ ' <i class="typeahead-image zulip-icon zulip-icon-user-group" aria-hidden="true"></i>\n' +
+ ' <div class="typeahead-text-container">\n' +
+ ' <strong class="typeahead-strong-section">hamletcharacters</strong> <span class="autocomplete_secondary">Characters of Hamlet</span>' +
+ " </div>\n" +
"</div>\n";
assert.equal(actual_value, expected_value);