From 67d2bb98916df9e0b5c9f56d0005074223e1275d Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 30 Jun 2024 19:13:13 +0300 Subject: [PATCH] Fix file pasting not working if Firefox --- public/scripts/chats.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/public/scripts/chats.js b/public/scripts/chats.js index 29d5462b0..e605f02db 100644 --- a/public/scripts/chats.js +++ b/public/scripts/chats.js @@ -1526,7 +1526,13 @@ jQuery(function () { const fileInput = document.getElementById('file_form_input'); if (!(fileInput instanceof HTMLInputElement)) return; - fileInput.files = event.clipboardData.files; + // Workaround for Firefox: Use a DataTransfer object to indirectly set fileInput.files + const dataTransfer = new DataTransfer(); + for (let i = 0; i < event.clipboardData.files.length; i++) { + dataTransfer.items.add(event.clipboardData.files[i]); + } + + fileInput.files = dataTransfer.files; await onFileAttach(fileInput.files[0]); }); });