From 2752d25570d2a24864a8acda255d7ab2575ac801 Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Wed, 2 Apr 2025 13:27:20 +0000 Subject: [PATCH] Bug 36275: (follow-up) Only show tooltip on successful copy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Question is whether we should display anything on the failure case as well? Test plan stays the same. Signed-off-by: Emmanuel Bétemps Signed-off-by: Nick Clemens --- koha-tmpl/intranet-tmpl/prog/js/copyToClipboard.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/copyToClipboard.js b/koha-tmpl/intranet-tmpl/prog/js/copyToClipboard.js index e82ee8ceb32..e5ca50f2325 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/copyToClipboard.js +++ b/koha-tmpl/intranet-tmpl/prog/js/copyToClipboard.js @@ -3,7 +3,7 @@ "[data-copy-to-clipboard]" ); if (copyToClipboardButtons.length) { - const copyToClipboard = e => { + const copyToClipboard = async e => { const target = e.target; if (!(target instanceof HTMLButtonElement)) { return; @@ -13,7 +13,11 @@ return; } - navigator.clipboard.writeText(value); + try { + await navigator.clipboard.writeText(value); + } catch (_) { + return; + } target.title = __("Copied to clipboard"); const tooltip = bootstrap.Tooltip.getOrCreateInstance(target); -- 2.39.5