Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the clipboard.ts for copying failure. #3176

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions frontend/src/utils/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,25 @@
textarea.style.outline = "none";
textarea.style.boxShadow = "none";
textarea.style.background = "transparent";
document.body.appendChild(textarea);

let body: Element | null = null;
const focusedElement = document.activeElement;
if (focusedElement){

Check warning on line 52 in frontend/src/utils/clipboard.ts

View workflow job for this annotation

GitHub Actions / lint-frontend

Insert `·`
body = focusedElement

Check warning on line 53 in frontend/src/utils/clipboard.ts

View workflow job for this annotation

GitHub Actions / lint-frontend

Insert `;`
}else{

Check warning on line 54 in frontend/src/utils/clipboard.ts

View workflow job for this annotation

GitHub Actions / lint-frontend

Replace `else` with `·else·`
body = document.body

Check warning on line 55 in frontend/src/utils/clipboard.ts

View workflow job for this annotation

GitHub Actions / lint-frontend

Insert `;`
}
body.appendChild(textarea)

Check warning on line 57 in frontend/src/utils/clipboard.ts

View workflow job for this annotation

GitHub Actions / lint-frontend

Insert `;`

textarea.focus();
textarea.select();
try {
document.execCommand("copy");
document.body.removeChild(textarea);
resolve();
} catch (e) {
document.body.removeChild(textarea);
reject(e);
}finally{

Check warning on line 66 in frontend/src/utils/clipboard.ts

View workflow job for this annotation

GitHub Actions / lint-frontend

Replace `finally` with `·finally·`
body.removeChild(textarea)

Check warning on line 67 in frontend/src/utils/clipboard.ts

View workflow job for this annotation

GitHub Actions / lint-frontend

Insert `;`
}
} else {
reject(
Expand Down
Loading