KarimMokhtar / react-drag-drop-files

Light and simple Reactjs drag and drop files library to use with very flexible options to change, so you put whatever the design you want for your drop-area. Users can drag and drop or even select the file anywhere in the window.
MIT License
245 stars 86 forks source link

#41 Do not call clearData() #43

Closed TroyWolf closed 2 years ago

TroyWolf commented 2 years ago

Per the documenation, we are only supposed to modify the drag operation's data store during the dragstart event. We were calling it in the drop event. This was not throwing errors in Chrome, but Firefox, for example would throw a NoModificationAllowedError.

Initially, I figured to move the call to dataTransfer.clearData() to the dragstart event handler. I noticed we did not even have a handler for this method. Then I realized this is because when a user drags a file into our dropzone, we never see the start event of that drag operation.

Therefore, I simply removed the call to dataTransfer.clearData().

KarimMokhtar commented 2 years ago

@TroyWolf Thanks for your contribution.