From 0b8b0072a2b3348b896029d9ba032a980a3496e1 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Thu, 19 Oct 2023 00:23:28 +0800 Subject: [PATCH] Clipboard copy enhancements (#27669) (#27681) Backport #27669 by @silverwind 1. Do not show temporary tooltips that are triggered from within dropdowns. Previously this resulted in the tooltip being stuck to top-left of the page like seen on issue comment URL copy. I could not figure out any tippy options that prevent this, so I think it's better to just not show it. 1. Refactor `initGlobalCopyToClipboardListener` so that it does not run a often useless `document.querySelector` on every click, make `data-clipboard-text-type` work with `data-clipboard-target`. No use in current code base but still good to have. Finally some minor code cleanup in the function. Point 1 is for this copy button: image Co-authored-by: silverwind --- web_src/js/features/clipboard.js | 21 ++++++++++++++------- web_src/js/modules/tippy.js | 5 +++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/web_src/js/features/clipboard.js b/web_src/js/features/clipboard.js index bcbdae270..224628658 100644 --- a/web_src/js/features/clipboard.js +++ b/web_src/js/features/clipboard.js @@ -4,19 +4,25 @@ import {clippie} from 'clippie'; const {copy_success, copy_error} = window.config.i18n; -// For all DOM elements with [data-clipboard-target] or [data-clipboard-text], -// this copy-to-clipboard will work for them +// Enable clipboard copy from HTML attributes. These properties are supported: +// - data-clipboard-text: Direct text to copy, has highest precedence +// - data-clipboard-target: Holds a selector for a or