buddy_list: Don't go to DM narrow on avatar click.

This commit also moves styles from user-presence-link
onto selectable_sidebar_block, since the link is no
longer wrapping the whole block contents.

The `data-name` was also moved to the top level `<li>`
because it's used in pupeteer tests.
This commit is contained in:
evykassirer 2024-10-24 12:13:44 -07:00 committed by Tim Abbott
parent 08e7c5feea
commit ce7c3705f7
4 changed files with 26 additions and 24 deletions

View File

@ -404,21 +404,21 @@ async function test_stream_search_filters_stream_list(page: Page): Promise<void>
async function test_users_search(page: Page): Promise<void> {
console.log("Search users using right sidebar");
async function assert_in_list(page: Page, name: string): Promise<void> {
await page.waitForSelector(`#buddy-list-other-users li [data-name="${CSS.escape(name)}"]`, {
await page.waitForSelector(`#buddy-list-other-users li[data-name="${CSS.escape(name)}"]`, {
visible: true,
});
}
async function assert_selected(page: Page, name: string): Promise<void> {
await page.waitForSelector(
`#buddy-list-other-users li.highlighted_user [data-name="${CSS.escape(name)}"]`,
`#buddy-list-other-users li.highlighted_user[data-name="${CSS.escape(name)}"]`,
{visible: true},
);
}
async function assert_not_selected(page: Page, name: string): Promise<void> {
await page.waitForSelector(
`#buddy-list-other-users li.highlighted_user [data-name="${CSS.escape(name)}"]`,
`#buddy-list-other-users li.highlighted_user[data-name="${CSS.escape(name)}"]`,
{hidden: true},
);
}
@ -452,7 +452,7 @@ async function test_users_search(page: Page): Promise<void> {
await arrow(page, "Down");
// Now Iago must be highlighted
await page.waitForSelector('#buddy-list-other-users li.highlighted_user [data-name="Iago"]', {
await page.waitForSelector('#buddy-list-other-users li.highlighted_user[data-name="Iago"]', {
visible: true,
});
await assert_not_selected(page, "King Hamlet");

View File

@ -440,6 +440,9 @@ export function initialize() {
if (e.metaKey || e.ctrlKey || e.shiftKey) {
return;
}
if ($(e.target).parents(".user-profile-picture").length === 1) {
return;
}
const $li = $(e.target).parents("li");

View File

@ -255,6 +255,7 @@ $user_status_emoji_width: 24px;
}
.user_sidebar_entry.with_avatar .selectable_sidebar_block {
margin: 3px;
grid-template:
"row-content markers-and-controls" var(--line-height-sidebar-row-with-avatars)
"row-content ." auto / minmax(0, 1fr)
@ -272,7 +273,7 @@ $user_status_emoji_width: 24px;
}
.information-settings .profile-with-avatar,
.user_sidebar_entry.with_avatar .user-presence-link {
.user_sidebar_entry.with_avatar .selectable_sidebar_block {
line-height: var(--line-height-sidebar-row-with-avatars);
display: grid;
grid-template: "avatar row-content" var(--right-sidebar-avatar-width) / auto minmax(
@ -287,10 +288,6 @@ $user_status_emoji_width: 24px;
margin: 5px 0;
}
.user_sidebar_entry.with_avatar .user-presence-link {
margin: 3px;
}
.my_user_status {
opacity: 0.5;
white-space: nowrap;

View File

@ -1,11 +1,8 @@
<li data-user-id="{{user_id}}" class="user_sidebar_entry {{#if user_list_style.WITH_AVATAR}}with_avatar{{/if}} {{#if is_current_user}}user_sidebar_entry_me {{/if}} narrow-filter {{#if faded}} user-fade {{/if}}">
<li data-user-id="{{user_id}}" data-name="{{name}}" class="user_sidebar_entry {{#if user_list_style.WITH_AVATAR}}with_avatar{{/if}} {{#if is_current_user}}user_sidebar_entry_me {{/if}} narrow-filter {{#if faded}} user-fade {{/if}}">
<div class="selectable_sidebar_block">
{{#unless user_list_style.WITH_AVATAR}}<span class="{{user_circle_class}} user_circle"></span>{{/unless}}
<a class="user-presence-link"
href="{{href}}"
data-user-id="{{user_id}}"
data-name="{{name}}">
{{#if user_list_style.WITH_STATUS}}
{{#if user_list_style.WITH_STATUS}}
<span class="{{user_circle_class}} user_circle"></span>
<a class="user-presence-link" href="{{href}}">
<div class="user-name-and-status-wrapper">
<div class="user-name-and-status-emoji">
{{> user_full_name}}
@ -13,11 +10,13 @@
</div>
<span class="status-text">{{status_text}}</span>
</div>
{{else if user_list_style.WITH_AVATAR}}
<div class="user-profile-picture">
<img loading="lazy" src="{{profile_picture}}"/>
<span class="{{user_circle_class}} user_circle"></span>
</div>
</a>
{{else if user_list_style.WITH_AVATAR}}
<div class="user-profile-picture">
<img loading="lazy" src="{{profile_picture}}"/>
<span class="{{user_circle_class}} user_circle"></span>
</div>
<a class="user-presence-link" href="{{href}}">
<div class="user-name-and-status-wrapper">
<div class="user-name-and-status-emoji">
{{> user_full_name}}
@ -25,13 +24,16 @@
</div>
<span class="status-text">{{status_text}}</span>
</div>
{{else}}
</a>
{{else}}
<span class="{{user_circle_class}} user_circle"></span>
<a class="user-presence-link" href="{{href}}">
<div class="user-name-and-status-emoji">
{{> user_full_name}}
{{> status_emoji status_emoji_info}}
</div>
{{/if}}
</a>
</a>
{{/if}}
<span class="unread_count {{#unless num_unread}}hide{{/unless}}">{{#if num_unread}}{{num_unread}}{{/if}}</span>
</div>
<span class="sidebar-menu-icon user-list-sidebar-menu-icon"><i class="zulip-icon zulip-icon-more-vertical" aria-hidden="true"></i></span>