Write to clipboard issue using Forge UIKit

Hello, I have been struggling making a copy to clipboard button using UIKit. We plan to use this app in our jira internally so security is of little concern. After googling I concluded that using the iframe from CustomUI makes writing to clipboard possible. But the app is already done using UIKit, and rewriting it to be in an iframe is a hassle at this point. Can anyone provide me with a solution to fix this issue.

  const copyToClipboard = (text) => {
    navigator.clipboard.writeText(text)
      .then(() => {
        console.log('Text copied to clipboard: ', text);
      })
      .catch(err => {
        console.error('Failed to copy text: ', err);
        setError('Failed to copy text: ' + err);
      });
  }

Failed to copy text: NotAllowedError: Failed to execute 'writeText' on 'Clipboard': Write permission denied.
1 Like

Hi @NikolaZlatkov , the clipboard copy capability is currently not supported in UI Kit. As a workaround you could write that part of your app within the new Frame component which would allow you to render a Custom UI resource within UI Kit so you don’t have to rewrite your whole app: https://developer.atlassian.com/platform/forge/ui-kit/components/frame/

Note that Frame currently supports the following modules for Jira listed here: https://developer.atlassian.com/platform/forge/ui-kit/components/frame/#supported-modules

I’ve raised a feature request to bring this natively into UI Kit here: [FRGE-1510] - Ecosystem Jira

2 Likes