-
Suggestion
-
Resolution: Unresolved
-
None
Issue Summary
Currently, due to lack of "clipboard-write " permission in iframe created for Bitbucket connect app, it is not possible to implement `copy` functionality without a workaround for chrome and safari.
However there is a possibility of copying data to the clipboard in Firefox. One can use the navigator.clipboard.writeText(text), and it will work because Firefox doesn’t implement the allow="clipboard-write" attribute.
Steps to Reproduce
- Install this Bitbucket connect sample app for copy functionality. Test-App-Modal.zip
- Once installed (use either chrome or safari) click on the copy button to copy the text
Expected Results
Text is copied to clipboard
Actual Results
Text is not copied to clipboard
Workaround
The only work around is to use a code similar to below, however this only works in Chrome and Safari and not on Firefox.
export const copyToClipboard = (text: string) => { const textarea = document.createElement('textarea') textarea.textContent = text textarea.style.position = 'fixed' document.body.appendChild(textarea) textarea.select() document.execCommand('copy') document.body.removeChild(textarea) }