From ba35eb8f8c6198da2b60eef7445e5aac8306c2b5 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Fri, 22 Oct 2021 21:04:04 +0200 Subject: [PATCH] fix: pasting images on firefox (#4085) --- src/components/App.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index fb4ff7bae6..858de11865 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1257,10 +1257,13 @@ class App extends React.Component { return; } - const data = await parseClipboard(event); - + // must be called in the same frame (thus before any awaits) as the paste + // event else some browsers (FF...) will clear the clipboardData + // (something something security) let file = event?.clipboardData?.files[0]; + const data = await parseClipboard(event); + if (!file && data.text) { const string = data.text.trim(); if (string.startsWith("")) {