From 512f056053d35952cd238f9c62bf0070aa47cd69 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 Question is whether we should display anything on the failure case as well? Test plan stays the same. --- 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 e82ee8ceb3..e5ca50f232 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