Updates onCopy functions to use navigator.clipboard instead of deprecated execCommand

This commit is contained in:
mabashian 2021-06-07 14:18:27 -04:00
parent 121db42699
commit 03209fe2f2
2 changed files with 6 additions and 18 deletions

View File

@ -165,15 +165,9 @@ function ProjectDetail({ project }) {
variant="inline-compact"
clickTip={t`Successfully copied to clipboard!`}
hoverTip={t`Copy full revision to clipboard.`}
onCopy={event => {
const clipboard = event.currentTarget.parentElement;
const el = document.createElement('textarea');
el.value = scm_revision.toString();
clipboard.appendChild(el);
el.select();
document.execCommand('copy');
clipboard.removeChild(el);
}}
onCopy={() =>
navigator.clipboard.writeText(scm_revision.toString())
}
>
{scm_revision.substring(0, 7)}
</ClipboardCopy>

View File

@ -97,15 +97,9 @@ function ProjectListItem({
variant="inline-compact"
clickTip={t`Successfully copied to clipboard!`}
hoverTip={t`Copy full revision to clipboard.`}
onCopy={event => {
const clipboard = event.currentTarget.parentElement;
const el = document.createElement('textarea');
el.value = project.scm_revision.toString();
clipboard.appendChild(el);
el.select();
document.execCommand('copy');
clipboard.removeChild(el);
}}
onCopy={() =>
navigator.clipboard.writeText(project.scm_revision.toString())
}
>
{project.scm_revision.substring(0, 7)}
</ClipboardCopy>