Answer the question
In order to leave comments, you need to log in
Why doesn't preventDefault work for the drop event?
I work on Angular 7 and faced such a problem - I can't implement drag n drop. preventDefault doesn't work and the file just opens in the browser.
In general, the markup in the component is as follows:
<div id="drop-area" (dragover)="preventDefaults($event)" (drop)="handleDrop($event)" (ngClass)="highlight">
...
</div>
preventDefaults(e){
e.preventDefault();
e.stopPropagation();
}
handleDrop(e){
preventDefaults(e);
console.log(e.dataTransfer.files);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question