Using the Clipboard API in the app iframe

simonhaenisch
Tourist
6 0 3

I just wanted to implement a label action that copies the text field's value to the users clipboard. It's very straight-forward:

 

<TextField
    readonly
    value={url}
    label="URL"
    labelAction={{ content: "Copy", onAction: async () => navigator.clipboard.writeText(url)}}
/>

 

However this does not work because the embedded app is an iframe and not allowed to access the Clipboard API, so I get an error.

DOMException: The Clipboard API has been blocked because of a Feature Policy applied to the current document. See https://goo.gl/EuHzyv for more details.

Apparently it's relatively straight-forward to allow the iframe access to this API, it just needs an "allow" attribute like

 

<iframe src="..." allow="clipboard-write"><iframe>

 

See https://web.dev/async-clipboard/#permissions-policy-integration.

But as an app developer of course I don't have control over the iframe's attributes, so this is a feature request, whether you could consider allowing certain APIs for embedded apps, specifically "clipboard-write"?

JeffKelley-rh
New Member
1 0 0

Having the same problem. Any help on this?

0 Likes