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

Blocks: Do not copy code snippet when text inside preview is selected #19788

Merged
merged 2 commits into from
Jan 14, 2023

Conversation

pocka
Copy link
Contributor

@pocka pocka commented Nov 9, 2022

Issue: #18611

What I did

Prevent the <Preview/> component from copying code snippets when a user tries to copy texts inside the preview.

I didn't change onCopyCapture to onCopy due to lacking context (code comment, commit message, or PR/issue comments). Therefore that event listener still interferes with an onCopy handler inside the preview.

(Which labels are suitable for this PR and the issue? There is no blocks label...)

How to test

  • Is this testable with Jest or Chromatic screenshots?
  • Does this need a new example in the kitchen sink apps?
  • Does this need an update to the documentation?

If your answer is yes to any of these, please make sure to include it in your PR.

#18611

This patch introduces skip conditional for the "copy code snippet
by shortcut key" feature.

this condition would not work when the preview is iframe (user sets
`docs: { inlineStories: false }`), but that does not matter as the
event handler won't run in the first place.
@pocka pocka added the bug label Nov 9, 2022
@pocka pocka marked this pull request as ready for review November 9, 2022 10:09
@shilman shilman added the ui label Nov 10, 2022
@ndelangen ndelangen assigned ndelangen and unassigned yannbf Jan 13, 2023
@ndelangen ndelangen assigned JReinhold and unassigned ndelangen Jan 14, 2023
@ndelangen ndelangen requested a review from JReinhold January 14, 2023 00:29
@JReinhold JReinhold merged commit df28d20 into next Jan 14, 2023
@JReinhold JReinhold deleted the pocka/fix/18611-cannot-copy-docs-preview-content-text branch January 14, 2023 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants