fix: ToolFileInput.tsx

This commit is contained in:
Ibrahima G. Coulibaly
2024-06-25 09:46:09 +01:00
parent 9f2dd774e7
commit 1e68c7105f

View File

@@ -26,12 +26,17 @@ export default function ToolFileInput({
const fileInputRef = useRef<HTMLInputElement>(null); const fileInputRef = useRef<HTMLInputElement>(null);
const handleCopy = () => { const handleCopy = () => {
if (value) {
const blob = new Blob([value], { type: value.type });
const clipboardItem = new ClipboardItem({ [value.type]: blob });
navigator.clipboard navigator.clipboard
.writeText(value?.name ?? '') .write([clipboardItem])
.then(() => showSnackBar('Text copied', 'success')) .then(() => showSnackBar('File copied', 'success'))
.catch((err) => { .catch((err) => {
showSnackBar('Failed to copy: ' + err, 'error'); showSnackBar('Failed to copy: ' + err, 'error');
}); });
}
}; };
useEffect(() => { useEffect(() => {
if (value) { if (value) {