Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
copy_link: Add onSuccess listener to copy clipboard.
Gaurav Pandey782fca79c465
diff --git a/frontend_tests/node_tests/popovers.js b/frontend_tests/node_tests/popovers.jsindex c36d1032952..4a1738b8acf 100644--- a/frontend_tests/node_tests/popovers.js+++ b/frontend_tests/node_tests/popovers.js@@ -100,7 +100,9 @@ function test_ui(label, f) {page_params.is_admin = false;page_params.realm_email_address_visibility = 3;page_params.custom_profile_fields = [];- override(popovers, "clipboard_enable", noop);+ override(popovers, "clipboard_enable", () => ({+ on: noop,+ }));popovers.clear_for_testing();popovers.register_click_handlers();f({override, mock_template});diff --git a/static/js/popovers.js b/static/js/popovers.jsindex a149108a4b9..68d8d6ea6c1 100644--- a/static/js/popovers.js+++ b/static/js/popovers.js@@ -1174,11 +1174,10 @@ export function register_click_handlers() {e.preventDefault();});- clipboard_enable(".copy_link");-- $("body").on("click", ".copy_link", function (e) {+ clipboard_enable(".copy_link").on("success", (e) => {hide_actions_popover();- const message_id = $(this).attr("data-message-id");+ // e.trigger returns the DOM element triggering the copy action+ const message_id = e.trigger.getAttribute("data-message-id");const row = $(`[zid='${CSS.escape(message_id)}']`);row.find(".alert-msg").text($t({defaultMessage: "Copied!"}))@@ -1191,9 +1190,6 @@ export function register_click_handlers() {// We unfocus this so keyboard shortcuts, etc., will work again.$(":focus").trigger("blur");}, 0);-- e.stopPropagation();- e.preventDefault();});clipboard_enable(".copy_mention_syntax");diff --git a/static/templates/actions_popover_content.hbs b/static/templates/actions_popover_content.hbsindex d3fa5970637..b3a5a8a001f 100644--- a/static/templates/actions_popover_content.hbs+++ b/static/templates/actions_popover_content.hbs@@ -97,7 +97,7 @@{{/if}}<li>- <a href="#" class="copy_link" data-message-id="{{message_id}}" data-clipboard-text="{{ conversation_time_uri }}">+ <a class="copy_link" data-message-id="{{message_id}}" data-clipboard-text="{{ conversation_time_uri }}"><i class="fa fa-link" aria-hidden="true"></i> {{t "Copy link to message" }}</a></li>