mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
fix #14: drag n drop must react only on files
This commit is contained in:
@@ -19,8 +19,21 @@ export default function ScreenDropArea({ children }: { children: React.ReactNode
|
|||||||
const handleDragEnter = (e: React.DragEvent<HTMLDivElement>) => {
|
const handleDragEnter = (e: React.DragEvent<HTMLDivElement>) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
dragCounter.current++
|
|
||||||
|
|
||||||
|
// Check if the dragged items are files
|
||||||
|
const items = e.dataTransfer.items
|
||||||
|
if (!items) return
|
||||||
|
|
||||||
|
let hasFiles = false
|
||||||
|
for (const item of items) {
|
||||||
|
if (item.kind === "file") {
|
||||||
|
hasFiles = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasFiles) return
|
||||||
|
|
||||||
|
dragCounter.current++
|
||||||
if (dragCounter.current === 1) {
|
if (dragCounter.current === 1) {
|
||||||
setIsDragging(true)
|
setIsDragging(true)
|
||||||
}
|
}
|
||||||
@@ -48,11 +61,12 @@ export default function ScreenDropArea({ children }: { children: React.ReactNode
|
|||||||
// Reset counter and dragging state
|
// Reset counter and dragging state
|
||||||
dragCounter.current = 0
|
dragCounter.current = 0
|
||||||
setIsDragging(false)
|
setIsDragging(false)
|
||||||
setIsUploading(true)
|
|
||||||
setUploadError("")
|
|
||||||
|
|
||||||
const files = e.dataTransfer.files
|
const files = e.dataTransfer.files
|
||||||
if (files && files.length > 0) {
|
if (files && files.length > 0) {
|
||||||
|
setIsUploading(true)
|
||||||
|
setUploadError("")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
if (transactionId) {
|
if (transactionId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user