From b4c1b10969a9d23e619e141c848dd1e51762676a Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 28 Dec 2023 10:42:23 +1100 Subject: [PATCH] FIX: copy link not working in non secure context (#25053) In non secure contexts (HTTP vs HTTPS) which many run in development the `clipboardCopy` method falls back to and an exec hack. However, callers expect a promise from this method and the fallback just returns a boolean. --- app/assets/javascripts/discourse/app/lib/utilities.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/lib/utilities.js b/app/assets/javascripts/discourse/app/lib/utilities.js index f666147a2a1..eb87dd093f0 100644 --- a/app/assets/javascripts/discourse/app/lib/utilities.js +++ b/app/assets/javascripts/discourse/app/lib/utilities.js @@ -494,7 +494,11 @@ export function clipboardCopy(text) { } // ...Otherwise, use document.execCommand() fallback - return clipboardCopyFallback(text); + if (clipboardCopyFallback(text)) { + return Promise.resolve(); + } else { + return Promise.reject(); + } } // Use this version of clipboardCopy if you must use an AJAX call