Skip to content

Commit

Permalink
Workaround clipboard copying bug
Browse files Browse the repository at this point in the history
Fixes #273
  • Loading branch information
luckyrat committed Oct 6, 2020
1 parent d150a86 commit 878140b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 14 additions & 1 deletion panels/copyStringToClipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
4 changes: 4 additions & 0 deletions release-notes/update-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ <h1 style="font-size: 42px; text-align: center;"><img src="/common/images/64.png
<div id="mainContent">
<div id="updateNotesContent">

<h2 style="margin-left:15px"><span data-i18n="version_upgrade_heading_changes"></span> 3.5.20</h2>

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

<h2 style="margin-left:15px"><span data-i18n="version_upgrade_heading_changes"></span> 3.5</h2>

<p data-i18n="list_version_upgrade_3_5"></p>
Expand Down

0 comments on commit 878140b

Please sign in to comment.