From 0fc1c36cb55ba4eca42d679a5f9ab43853377239 Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Tue, 2 Jan 2024 13:06:22 -0500 Subject: [PATCH] fix: copy to clipboard --- .changeset/khaki-badgers-leave.md | 10 ++++++++++ libs/design-system/package.json | 1 + libs/design-system/src/lib/clipboard.ts | 5 +++-- package-lock.json | 13 +++++++++++++ package.json | 1 + 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .changeset/khaki-badgers-leave.md diff --git a/.changeset/khaki-badgers-leave.md b/.changeset/khaki-badgers-leave.md new file mode 100644 index 000000000..1a2a80e7c --- /dev/null +++ b/.changeset/khaki-badgers-leave.md @@ -0,0 +1,10 @@ +--- +'website': minor +'@siafoundation/design-system': minor +'explorer': minor +'hostd': minor +'renterd': minor +'walletd': minor +--- + +Fixed an issue with the copy to clipboard feature. diff --git a/libs/design-system/package.json b/libs/design-system/package.json index 854d82c01..d002133b8 100644 --- a/libs/design-system/package.json +++ b/libs/design-system/package.json @@ -47,6 +47,7 @@ "@visx/tooltip": "^2.17.0", "@visx/event": "^2.17.0", "d3-array": "^3.1.6", + "clipboard-polyfill": "^4.0.1", "@visx/xychart": "^2.18.0", "react-dropzone": "^14.2.3", "@radix-ui/react-radio-group": "^1.0.0", diff --git a/libs/design-system/src/lib/clipboard.ts b/libs/design-system/src/lib/clipboard.ts index a3aa6c446..a1daba266 100644 --- a/libs/design-system/src/lib/clipboard.ts +++ b/libs/design-system/src/lib/clipboard.ts @@ -1,4 +1,5 @@ import React from 'react' +import * as clipboard from 'clipboard-polyfill' import { ToastOptions, triggerToast, triggerToastNode } from './toast' export const copyToClipboard = (text: string, entity?: string) => { @@ -6,7 +7,7 @@ export const copyToClipboard = (text: string, entity?: string) => { ? `Copied ${entity} to clipboard` : 'Copied to clipboard' triggerToast(message) - navigator.clipboard.writeText(text) + clipboard.writeText(text) } export const copyToClipboardCustom = ( @@ -15,5 +16,5 @@ export const copyToClipboardCustom = ( options?: ToastOptions ) => { triggerToastNode(message, options) - navigator.clipboard.writeText(text) + clipboard.writeText(text) } diff --git a/package-lock.json b/package-lock.json index 382d60319..2b5b0e2fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -59,6 +59,7 @@ "bignumber.js": "^9.0.2", "blakejs": "^1.2.1", "class-variance-authority": "^0.7.0", + "clipboard-polyfill": "^4.0.1", "cmdk": "^0.2.0", "cobe": "^0.6.3", "core-js": "^3.6.5", @@ -296,6 +297,7 @@ "@visx/shape": "^2.18.0", "@visx/tooltip": "^2.17.0", "@visx/xychart": "^2.18.0", + "clipboard-polyfill": "^4.0.1", "d3-array": "^3.1.6", "date-fns": "^2.28.0", "formik": "^2.2.9", @@ -11221,6 +11223,11 @@ "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==" }, + "node_modules/clipboard-polyfill": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clipboard-polyfill/-/clipboard-polyfill-4.0.1.tgz", + "integrity": "sha512-oOxooaJd9dzy78jk1fw4IL+J0SiBn+W24KqUYUwsr0OWEsb5aZlKAWglr9Fg/XEFQMT3ZmJ2AnRoRMZZOMcOQQ==" + }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -33271,6 +33278,7 @@ "@visx/shape": "^2.18.0", "@visx/tooltip": "^2.17.0", "@visx/xychart": "^2.18.0", + "clipboard-polyfill": "^4.0.1", "d3-array": "^3.1.6", "date-fns": "^2.28.0", "formik": "^2.2.9", @@ -36136,6 +36144,11 @@ "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==" }, + "clipboard-polyfill": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clipboard-polyfill/-/clipboard-polyfill-4.0.1.tgz", + "integrity": "sha512-oOxooaJd9dzy78jk1fw4IL+J0SiBn+W24KqUYUwsr0OWEsb5aZlKAWglr9Fg/XEFQMT3ZmJ2AnRoRMZZOMcOQQ==" + }, "cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", diff --git a/package.json b/package.json index 2a1008b0c..29a559559 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "bignumber.js": "^9.0.2", "blakejs": "^1.2.1", "class-variance-authority": "^0.7.0", + "clipboard-polyfill": "^4.0.1", "cmdk": "^0.2.0", "cobe": "^0.6.3", "core-js": "^3.6.5",