You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The copy-to-clipboard logic is failing in the interactive example <iframe> due to lack of clipboard-write permissions for the Clipboard API.
To use the API in iframes, you need to enable it with Permissions Policy, which defines a mechanism that allows for selectively enabling and disabling various browser features and APIs. Concretely, you need to pass either or both of clipboard-read or clipboard-write, depending on the needs of your app.
maybe we could make the {{EmbedInteractiveExample}} macros able to passing a parameter to specified allow attribute on the <iframe> element, just like the {{EmbedLiveSample}} does
@skyclouds2001 that could be an option, since the EmbedLiveSample macro supports a parameter for allowed features ($6) it makes sense that the EmbedInteractiveExample macro might do something similar. I'm just not sure if the interactive examples need any other permissions currently other than clipboard API. I added allow="clipboard-write" directly to the <iframe> in EmbedInteractiveExample.ejs for my initial PR (#10910) to quickly validate that the copy-to-clipboard worked again in interactive examples without having to update the actual EmbedInteractiveExample() macro calls throughout the various pages.
I searched mdn/content and found 1256 results in 1253 files of EmbedInteractiveExample( which would mean doing a mass search-and-replace to add a third argument with the "clipboard-write" permission, that is assuming all the interactive examples have code snippets which can be copied to clipboard. If the mdn folks are cool with that extra work of adding another parameter to the EmbedInteractiveExample macro to account for allowed features and updating those 1253 files in mdn/content then I can update my PR here to reflect that and submit one in mdn/content, otherwise I think simply adding the clipboard-write permission to the iframes directly gets the job done.
Summary
The copy-to-clipboard logic is failing in the interactive example
<iframe>
due to lack of clipboard-write permissions for the Clipboard API.URL
Reproduction steps
Expected behavior
Expected content to be copied to clipboard within interactive examples
Actual behavior
Fails to copy content to clipboard and logs error to the browser console
Device
Desktop
Browser
Chrome
Browser version
Stable
Operating system
Mac OS
Screenshot
copy-to-clipboard-iframe-error.mov
Anything else?
No response
Validations
The text was updated successfully, but these errors were encountered: