frontend: ignore drop event in form, trigger upload instead of file input dialog (fixes #74, maybe)

This commit is contained in:
Paul Bienkowski 2021-05-13 20:17:08 +02:00
parent 5193acd9cd
commit 798ff9fb1b
2 changed files with 3 additions and 0 deletions

View file

@ -160,6 +160,7 @@ export default class FileDrop extends React.PureComponent<FileDropProps, FileDro
} }
handleDrop: ReactDragEventHandler<HTMLDivElement> = (event) => { handleDrop: ReactDragEventHandler<HTMLDivElement> = (event) => {
event.preventDefault?.()
if (this.props.onDrop && FileDrop.eventHasFiles(event)) { if (this.props.onDrop && FileDrop.eventHasFiles(event)) {
const files = event.dataTransfer ? event.dataTransfer.files : null const files = event.dataTransfer ? event.dataTransfer.files : null
this.props.onDrop(files, event) this.props.onDrop(files, event)

View file

@ -18,6 +18,8 @@ export default function FileUploadField({onSelect: onSelect_, multiple}) {
) )
function onChangeField(e) { function onChangeField(e) {
e.preventDefault?.()
if (e.target.files && e.target.files.length) { if (e.target.files && e.target.files.length) {
onSelect(e.target.files) onSelect(e.target.files)
} }