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

feat: add native copy method #1852

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

feat: add native copy method #1852

wants to merge 5 commits into from

Conversation

ogonkov
Copy link
Contributor

@ogonkov ogonkov commented Sep 12, 2024

Fixes #658

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@gravity-ui-bot
Copy link
Contributor

Visual Tests Report is ready.

@@ -0,0 +1,7 @@
export function copyText(text: string) {
if (navigator.clipboard.writeText) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

navigator?.clipboard?.writeText ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if is better for possible stackatrace investigation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it is possible that application will fail, if there's no clipboard in navigator proto. We don't use try ... catch when using copyText.
I suggested not removing if, but add checks like if (navigator?.clipboard?.writeText) { ... }

src/components/CopyToClipboard/CopyToClipboard.tsx Outdated Show resolved Hide resolved
@ogonkov ogonkov requested a review from Raubzeug October 11, 2024 19:40
@@ -0,0 +1,7 @@
export function copyText(text: string) {
if (navigator.clipboard.writeText) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it is possible that application will fail, if there's no clipboard in navigator proto. We don't use try ... catch when using copyText.
I suggested not removing if, but add checks like if (navigator?.clipboard?.writeText) { ... }

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.

Get rid of react-copy-to-clipboard
3 participants