electron: Dropping items onto a webview doesn't trigger the 'drop' event

  • Electron version: 1.6.0
  • Operating system: OSX

Expected behavior

Expecting event ‘drop’ on the document object to fire

Actual behavior

Electron triggers a file open dialogue

How to reproduce

  1. Bind the drop event in the BrowserWindow control, ie;
document.addEventListener('drop',function(event){
      console.log("I'm getting " + event.dataTransfer.files.length); 
});
  1. Drop a file into a webview in the browser window. Event listener doesn’t fire. Fires in stable versions of electron. This may be intended but it used to fire the event. Version 1.4.15 fires the event even if dropped into a webview

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 17 (8 by maintainers)

Most upvoted comments

On Windows it works. event.preventDefault() both in document.ondragover and drop prevents the opening of the file. If either missing it will open the file, if not prevented in the ondragover then your drop event doesn’t run at all. Same behavior in 1.4.15 and 1.6 beta on Windows.