diff --git a/panels/copyStringToClipboard.ts b/panels/copyStringToClipboard.ts index 8fc96c02..03ab3daf 100644 --- a/panels/copyStringToClipboard.ts +++ b/panels/copyStringToClipboard.ts @@ -4,6 +4,19 @@ export async function copyStringToClipboard(value: string) { try { await navigator.clipboard.writeText(value); } catch (e) { - KeeLog.error("Failed to write to clipboard"); + try { + // Fallback to old textarea hack if required. + // See https://github.com/kee-org/browser-addon/issues/273 + const copyFrom = document.createElement("textarea"); + copyFrom.textContent = value; + const body = document.getElementsByTagName("body")[0]; + body.appendChild(copyFrom); + copyFrom.select(); + document.execCommand("copy"); + body.removeChild(copyFrom); + KeeLog.info("Failed to write to clipboard using modern API so used the fallback hack"); + } catch (e2) { + KeeLog.error("Failed to write to clipboard using modern API and fallback hack"); + } } } diff --git a/release-notes/update-notes.html b/release-notes/update-notes.html index 6237b0b0..90cb7695 100644 --- a/release-notes/update-notes.html +++ b/release-notes/update-notes.html @@ -15,6 +15,10 @@

+

3.5.20

+ +

Fixes a bug that caused copying existing and generated passwords to the clipboard to fail in some circumstances.

+

3.5