From b80d914cba0158a559162f1d019f836c004dee6b Mon Sep 17 00:00:00 2001 From: Matt Harrison Date: Mon, 7 Mar 2022 12:37:54 -0500 Subject: [PATCH] fix click to copy when there is more than one copy link on the page. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes issue reported on the mailing list here: https://lists.archlinux.org/pipermail/aur-general/2022-March/036833.html Thanks to Henry-Joseph Audéoud for diagnosing the issue https://lists.archlinux.org/pipermail/aur-general/2022-March/036836.html Also update the event variable to use the local copy instead of the deprecated global version https://stackoverflow.com/questions/58341832/event-is-deprecated-what-should-be-used-instead --- web/html/js/copy.js | 4 ++-- web/template/pkg_details.php | 4 ++-- web/template/pkgbase_details.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web/html/js/copy.js b/web/html/js/copy.js index f46299b3..21324ccb 100644 --- a/web/html/js/copy.js +++ b/web/html/js/copy.js @@ -1,6 +1,6 @@ document.addEventListener('DOMContentLoaded', function() { - document.querySelector('.copy').addEventListener('click', function(e) { + document.querySelectorAll('.copy').addEventListener('click', function(e) { e.preventDefault(); - navigator.clipboard.writeText(event.target.text); + navigator.clipboard.writeText(e.target.text); }); }); diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index 047de9a7..25d85b78 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -309,9 +309,9 @@ endif; diff --git a/web/template/pkgbase_details.php b/web/template/pkgbase_details.php index 35ad217a..bde29c1c 100644 --- a/web/template/pkgbase_details.php +++ b/web/template/pkgbase_details.php @@ -138,9 +138,9 @@ endif;