Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose_tooltips: Change new conversation button tooltip logic.
Sayam Samalf00d79399ee2
diff --git a/web/src/compose_closed_ui.js b/web/src/compose_closed_ui.jsindex 261f318b37c..8ae80595b50 100644--- a/web/src/compose_closed_ui.js+++ b/web/src/compose_closed_ui.js@@ -129,10 +129,7 @@ export function update_buttons_for_private() {!narrow_state.pm_ids_string() ||people.user_can_direct_message(narrow_state.pm_ids_string())) {- $("#new_conversation_button").attr(- "data-tooltip-template-id",- "new_direct_message_button_tooltip_template",- );+ $("#new_conversation_button").attr("data-conversation-type", "direct");update_buttons(text_stream, is_direct_message_narrow);return;}@@ -148,19 +145,13 @@ export function update_buttons_for_private() {export function update_buttons_for_stream_views() {const text_stream = $t({defaultMessage: "Start new conversation"});- $("#new_conversation_button").attr(- "data-tooltip-template-id",- "new_topic_message_button_tooltip_template",- );+ $("#new_conversation_button").attr("data-conversation-type", "stream");update_buttons(text_stream);}export function update_buttons_for_non_stream_views() {const text_stream = $t({defaultMessage: "Start new conversation"});- $("#new_conversation_button").attr(- "data-tooltip-template-id",- "new_stream_message_button_tooltip_template",- );+ $("#new_conversation_button").attr("data-conversation-type", "non-stream");update_buttons(text_stream);}diff --git a/web/src/compose_tooltips.js b/web/src/compose_tooltips.jsindex 800c9058e6e..4ecd4b21c61 100644--- a/web/src/compose_tooltips.js+++ b/web/src/compose_tooltips.js@@ -21,7 +21,6 @@ export function initialize() {// reply button's actual area is its containing span."#compose_buttons .compose_reply_button","#left_bar_compose_mobile_button_big",- "#new_conversation_button","#new_direct_message_button",],delay: EXTRA_LONG_HOVER_DELAY,@@ -35,6 +34,39 @@ export function initialize() {},});+ delegate("body", {+ target: "#new_conversation_button",+ delay: EXTRA_LONG_HOVER_DELAY,+ // Only show on mouseenter since for spectators, clicking on these+ // buttons opens login modal, and Micromodal returns focus to the+ // trigger after it closes, which results in tooltip being displayed.+ trigger: "mouseenter",+ appendTo: () => document.body,+ onShow(instance) {+ const $elem = $(instance.reference);+ const conversation_type = $elem.attr("data-conversation-type");+ if (conversation_type === "direct") {+ instance.setContent(+ parse_html($("#new_direct_message_button_tooltip_template").html()),+ );+ return;+ } else if (conversation_type === "stream") {+ instance.setContent(+ parse_html($("#new_topic_message_button_tooltip_template").html()),+ );+ return;+ }+ // Use new_stream_message_button_tooltip_template when the+ // conversation_type is equal to "non-stream" and also as a default fallback.+ instance.setContent(+ parse_html($("#new_stream_message_button_tooltip_template").html()),+ );+ },+ onHidden(instance) {+ instance.destroy();+ },+ });+delegate("body", {// Only display Tippy content on classes accompanied by a `data-` attribute.target: `