React Code Snippet copy button not working
See original GitHub issueWhat package(s) are you using?
-
carbon-components
-
carbon-components-react
Detailed description
Describe in detail the issue you’re having
- go to http://react.carbondesignsystem.com/?path=/story/codesnippet--single-line
- click the copy button
- paste it somewhere else
Is this issue related to a specific component?
CodeSnippet
, but may affect other components that are using the copy button
What did you expect to happen? What happened instead? What would you like to see changed?
- I expected it to copy the text snippet. It didn’t.
What browser are you working in?
- Chrome Version 77.0.3865.120 (Official Build) (64-bit)
- MacOS Catalina
What version of the Carbon Design System are you using?
- Whatever’s on your demo page
What offering/product do you work on? Any pressing ship or release dates we should be aware of?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
How to add copy code snippet button in React - Stack Overflow
I want users to click on a button and copy this entire code as such. But it's not working.
Read more >Implementing copy-to-clipboard in React with Clipboard API
Improve user experience by implementing a copy-to-clipboard button in React with the JavaScript Clipboard API or with third-party libraries.
Read more >An easy way for adding Copy to Clipboard functionality in ...
In this article, we will see how to use the most popular React library for adding copy to clipboard functionality in React app....
Read more >Add Copy To Clipboard Button to React Syntax Highlighter
In this video series, I work on my new personal website built using React.Website: https://www.celikk.
Read more >react-copy-to-clipboard - npm
Start using react-copy-to-clipboard in your project by running `npm i react-copy-to-clipboard`. There are 1358 other projects in the npm ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@asudoh / @repjarms I thank you two for continuing to address this. We - IBM Cognos - have also ran into this issue and will benefit from the fix.
I would like to make a request. In @repjarms’s comment on Jan 30 the it was mentioned to override the onClick - and I agree this is needed. But I think there’s also a case for not overriding but to propagate the onClick.
Usecase (we have this situation):
I’m not sure the best way to accomplish this. Maybe an additional prop to indicating if the copy-to-clipboard should happen (or not happen). const copyToClipboard = this.props.copyToClipboard ?? this.props.onClick ? false : true;
IIRC we historically let application code to do the actual copying due to the nature of requiring 3rd party library (back then). This may have changed now and feel free to implement the copying if anybody finds a cross-browser/lightweight way to do that.