From ff31759423dc1baaf1daeecca5e60d32f99d0b67 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Fri, 8 Mar 2024 16:33:12 +0530 Subject: [PATCH] Fix target determination in the copy programmatic output button --- src/khoj/interface/web/chat.html | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/khoj/interface/web/chat.html b/src/khoj/interface/web/chat.html index 11ea316f..2fafde15 100644 --- a/src/khoj/interface/web/chat.html +++ b/src/khoj/interface/web/chat.html @@ -29,17 +29,18 @@ To get started, just start typing below. You can also type / to see a list of co let chatOptions = []; function copyProgrammaticOutput(event) { // Remove the first 4 characters which are the "Copy" button - const programmaticOutput = event.target.parentNode.textContent.trim(); + const button = event.currentTarget; + const programmaticOutput = button.parentNode.textContent.trim(); navigator.clipboard.writeText(programmaticOutput).then(() => { - event.target.textContent = "✅ Copied to clipboard!"; + button.textContent = "✅ Copied to clipboard!"; setTimeout(() => { - event.target.textContent = "✅"; + button.textContent = "✅"; }, 1000); }).catch((error) => { console.error("Error copying programmatic output to clipboard:", error); - event.target.textContent = "⛔️ Failed to copy!"; + button.textContent = "⛔️ Failed to copy!"; setTimeout(() => { - event.target.textContent = "⛔️"; + button.textContent = "⛔️"; }, 1000); }); }