Mr. Tono’s tray: a real drop zone, real drag events, and a FormData the simulated village office reads. What happens when one preventDefault is forgotten? An…
Drag-and-drop upload is everywhere: avatars, attachments, CSV imports. The API is small but full of traps: without preventDefault() in dragover the feature is dead and the browser opens the file, the zone’s highlight flickers over child elements, files vanish after an await, and a hand-written Content-Type leaves the server unable to read the upload.
A drop zone prevents twice, and its contents exist only during the event
ondrop, with no preventDefault() in ondragover Call e.preventDefault() in dragover. Without it the element is no drop target: drop never comes and the browser opens the file.dragleave. Count: dragenter +1, dragleave −1, lit while the count is above 0 (the browser enters the child before it leaves the parent).e.dataTransfer.files after an await dataTransfer can be read only during the drop event. Copy [...e.dataTransfer.files] before any await, then use the copy.preventDefault() in dragover ondrop is never called.add / remove glow The glow goes out though the file is still over the tray.files after an await The list is already empty.