Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow clipboard permissions in iframe preview #7545

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevin940726
Copy link

What kind of change does this PR introduce?

I would say it's both a bug fix and a feature? Not sure.

What is the current behavior?

Currently, copying and pasting from the clipboard doesn't work in the preview iframe in the editor. This is because the preview frame is in another domain and some browsers (chrome and firefox for instance) block cross-origin access to the clipboard. Based on this article, the solution is to add the necessary permission to the allow attribute for the iframe. However, clipboard permissions are missing in the allow list.

What is the new behavior?

Add clipboard-read and clipboard-write to the preview frame to allow accessing the clipboard.

What steps did you take to test this? This is required before we can merge, make sure to test the flow you've updated.

  1. Visit https://codesandbox.io/s/eager-bird-087o05?file=/index.html
  2. Click on the button in the iframe preview. Notice there's an error outputted on top but not the copied content.
  3. Use devtools to add clipboard-read to the allow list of the iframe, and reload the iframe (it will not work without reloading).
  4. Try again, and the copied content should now show on the screen.

Checklist

  • Documentation N/A
  • Testing
  • Ready to be merged
  • Added myself to contributors table

@codesandbox
Copy link

codesandbox bot commented Mar 29, 2023

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit fed645a:

Sandbox Source
Notifications Test Configuration
mutable-mountain-r856rm PR

@CompuIves CompuIves self-requested a review April 19, 2023 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant