From 89a0fb1dd66228ecf814f236b69081d95ed6f0f9 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:10:37 +0100 Subject: [PATCH] new fallback approach --- .../components/modal-confirmation.blade.php | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php index 94f1f84f4..e23393abb 100644 --- a/resources/views/components/modal-confirmation.blade.php +++ b/resources/views/components/modal-confirmation.blade.php @@ -101,24 +101,18 @@ }, 2000); }); } else { - const textarea = document.createElement('textarea'); - textarea.value = this.confirmationText; - textarea.style.position = 'absolute'; - textarea.style.left = '-9999px'; - textarea.style.top = '0'; - document.body.appendChild(textarea); - textarea.select(); - try { - document.execCommand('copy'); - this.copied = true; - setTimeout(() => { - this.copied = false; - }, 2000); - } catch (err) { - console.error('Failed to copy text:', err); - } finally { - document.body.removeChild(textarea); - } + const input = document.createElement('input'); + input.setAttribute('readonly', ''); + input.setAttribute('value', this.confirmationText); + document.body.appendChild(input); + input.select(); + input.setSelectionRange(0, 99999); + document.execCommand('copy'); + document.body.removeChild(input); + this.copied = true; + setTimeout(() => { + this.copied = false; + }, 2000); } }, toggleAction(id) {