From ad68566ce533574afd5a56c71fb5678a3d4ef69b Mon Sep 17 00:00:00 2001 From: lakhoune Date: Thu, 30 Nov 2023 17:10:42 +0100 Subject: [PATCH] fix copy to clipboard --- .../recommender/custom-improvements.js | 15 ++++++++++++++- .../recommender/general-improvements.js | 16 +++++++++++++++- .../recommender/intent-improvements.js | 15 ++++++++++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/statistics/recommender/custom-improvements.js b/src/statistics/recommender/custom-improvements.js index 44734a7..8235f8e 100644 --- a/src/statistics/recommender/custom-improvements.js +++ b/src/statistics/recommender/custom-improvements.js @@ -218,7 +218,20 @@ class IntentImprovement extends LitElement { copyToClipboard() { const resDiv = this.shadowRoot.querySelector("#chatgptRes"); - navigator.clipboard.writeText(resDiv.innerText); + const clipBoardBtn = this.shadowRoot.querySelector( + "#copyToClipboardButton" + ); + try { + navigator.clipboard.writeText(resDiv.innerText); + clipBoardBtn.classList.remove("btn-outline-secondary"); + clipBoardBtn.classList.add("btn-success"); + setTimeout(() => { + clipBoardBtn.classList.remove("btn-success"); + clipBoardBtn.classList.add("btn-outline-secondary"); + }, 1000); + } catch (error) { + console.error(error); + } } } diff --git a/src/statistics/recommender/general-improvements.js b/src/statistics/recommender/general-improvements.js index 3c36fc3..a041162 100644 --- a/src/statistics/recommender/general-improvements.js +++ b/src/statistics/recommender/general-improvements.js @@ -56,6 +56,7 @@ class GeneralImprovement extends LitElement {