I have a copy button created by javascript, and its has onclick event like this:
let copyButton = document.createElement("button");
copyButton.onclick = {
const textLabel = document.createElement('textarea');
textLabel.value = copyText;
document.body.appendChild(textLabel);
textLabel.select();
document.execCommand('copy');
document.body.removeChild(textLabel);
};
It is lose focus when I click this button because the textLabel.select() function call.
What should I do to fix this issue?
Thanks so much.