From 1e68c7105f2d942dbe1dfd429009221911e5f8c9 Mon Sep 17 00:00:00 2001 From: "Ibrahima G. Coulibaly" Date: Tue, 25 Jun 2024 09:46:09 +0100 Subject: [PATCH] fix: ToolFileInput.tsx --- src/components/input/ToolFileInput.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/input/ToolFileInput.tsx b/src/components/input/ToolFileInput.tsx index b2189ea..64f4128 100644 --- a/src/components/input/ToolFileInput.tsx +++ b/src/components/input/ToolFileInput.tsx @@ -26,12 +26,17 @@ export default function ToolFileInput({ const fileInputRef = useRef(null); const handleCopy = () => { - navigator.clipboard - .writeText(value?.name ?? '') - .then(() => showSnackBar('Text copied', 'success')) - .catch((err) => { - showSnackBar('Failed to copy: ' + err, 'error'); - }); + if (value) { + const blob = new Blob([value], { type: value.type }); + const clipboardItem = new ClipboardItem({ [value.type]: blob }); + + navigator.clipboard + .write([clipboardItem]) + .then(() => showSnackBar('File copied', 'success')) + .catch((err) => { + showSnackBar('Failed to copy: ' + err, 'error'); + }); + } }; useEffect(() => { if (value) {