Prevent Electron app from redirecting when drag+dropping items in window
A concise version using ES6 syntax (working for me under Electron 1.4.1)
document.addEventListener('dragover', event => event.preventDefault())
document.addEventListener('drop', event => event.preventDefault())
Found a fix for Windows Electron v2.3.1 Windows Electron v0.30.0
the code should have listeners for both dragover
AND drop
.
document.addEventListener('dragover',function(event){
event.preventDefault();
return false;
},false);
document.addEventListener('drop',function(event){
event.preventDefault();
return false;
},false);
Electron will still redirect to the dropped file if you only listen to dragover
or drop
.
Cheers!