From 08e7c5feea5329550529673989bd1aabc32ba641 Mon Sep 17 00:00:00 2001 From: evykassirer Date: Fri, 25 Oct 2024 12:50:03 -0700 Subject: [PATCH] buddy_list: Refactor click handlers to not rely on placement of user-presence-link. --- web/src/click_handlers.js | 25 ++++++++++++------------- web/src/user_card_popover.js | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/web/src/click_handlers.js b/web/src/click_handlers.js index 3530238a7c..75fe846133 100644 --- a/web/src/click_handlers.js +++ b/web/src/click_handlers.js @@ -515,8 +515,9 @@ export function initialize() { // BUDDY LIST TOOLTIPS (not displayed on touch devices) $(".buddy-list-section").on("mouseenter", ".selectable_sidebar_block", (e) => { e.stopPropagation(); - const $elem = $(e.currentTarget).closest(".user_sidebar_entry").find(".user-presence-link"); - const user_id_string = $elem.attr("data-user-id"); + const user_id_string = $(e.currentTarget) + .closest(".user_sidebar_entry") + .attr("data-user-id"); const title_data = buddy_data.get_title_data(user_id_string, false); // `target_node` is the `ul` element since it stays in DOM even after updates. @@ -531,28 +532,26 @@ export function initialize() { ); } - do_render_buddy_list_tooltip( - $elem.parent(), - title_data, - get_target_node, - check_reference_removed, - ); + const $elem = $(e.currentTarget) + .closest(".user_sidebar_entry") + .find(".selectable_sidebar_block"); + do_render_buddy_list_tooltip($elem, title_data, get_target_node, check_reference_removed); /* The following implements a little tooltip giving the name for status emoji when hovering them in the right sidebar. This requires special logic, to avoid conflicting with the main tooltip or showing duplicate tooltips. */ - $(".user-presence-link .status-emoji-name").off("mouseenter").off("mouseleave"); - $(".user-presence-link .status-emoji-name").on("mouseenter", () => { - const instance = $elem.parent()[0]._tippy; + $(".user_sidebar_entry .status-emoji-name").off("mouseenter").off("mouseleave"); + $(".user_sidebar_entry .status-emoji-name").on("mouseenter", () => { + const instance = $elem[0]._tippy; if (instance && instance.state.isVisible) { instance.destroy(); } }); - $(".user-presence-link .status-emoji-name").on("mouseleave", () => { + $(".user_sidebar_entry .status-emoji-name").on("mouseleave", () => { do_render_buddy_list_tooltip( - $elem.parent(), + $elem, title_data, get_target_node, check_reference_removed, diff --git a/web/src/user_card_popover.js b/web/src/user_card_popover.js index d05bab4398..270d8f68c5 100644 --- a/web/src/user_card_popover.js +++ b/web/src/user_card_popover.js @@ -526,7 +526,7 @@ function get_user_card_popover_for_message_items() { // Functions related to the user card popover in the user sidebar. function toggle_sidebar_user_card_popover($target) { - const user_id = elem_to_user_id($target.find("a")); + const user_id = elem_to_user_id($target); const user = people.get_by_user_id(user_id); // Hiding popovers may mutate current_user_sidebar_user_id.