[daggy u] Fix iframed snippet copy behavior #19069
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary & Motivation
We received a report from a Dagster University user that the button to copy code snippets is failing in Chrome, due to a permissions limitation on the Clipboard API. I'm not sure if this has been broken for a while, but I was able to repro the issue.
Work around this by using the old fashioned
execCommand
behavior to write to the clipboard without the Clipboard API.How I Tested These Changes
yarn build, yarn start. Load an iframe with no
allow
values set, with a course page loaded:(In comparison, the Thinkific iframe allows a handful of features, but similarly does not allow any Clipboard access.)
Scroll to a code snippet, verify that I can successfully copy the snippet using the clipboard button. Verify also that newlines and whitespace are correct.