From 798ff9fb1b5877ba70b9f5fc4ce07e6df1c2ce13 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Thu, 13 May 2021 20:17:08 +0200 Subject: [PATCH] frontend: ignore drop event in form, trigger upload instead of file input dialog (fixes #74, maybe) --- frontend/src/components/FileDrop.tsx | 1 + frontend/src/components/FileUploadField.tsx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/frontend/src/components/FileDrop.tsx b/frontend/src/components/FileDrop.tsx index 340944e..0f03b00 100644 --- a/frontend/src/components/FileDrop.tsx +++ b/frontend/src/components/FileDrop.tsx @@ -160,6 +160,7 @@ export default class FileDrop extends React.PureComponent = (event) => { + event.preventDefault?.() if (this.props.onDrop && FileDrop.eventHasFiles(event)) { const files = event.dataTransfer ? event.dataTransfer.files : null this.props.onDrop(files, event) diff --git a/frontend/src/components/FileUploadField.tsx b/frontend/src/components/FileUploadField.tsx index 36c8f68..f3071e3 100644 --- a/frontend/src/components/FileUploadField.tsx +++ b/frontend/src/components/FileUploadField.tsx @@ -18,6 +18,8 @@ export default function FileUploadField({onSelect: onSelect_, multiple}) { ) function onChangeField(e) { + e.preventDefault?.() + if (e.target.files && e.target.files.length) { onSelect(e.target.files) }