Skip to content

Commit

Permalink
Drop Zone: Always reset drop state on mouse up
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Dec 7, 2015
1 parent 85fff41 commit 74d26d7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/components/drop-zone/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = React.createClass( {
window.addEventListener( 'drop', this.onDrop );
window.addEventListener( 'dragenter', this.toggleDraggingOverDocument );
window.addEventListener( 'dragleave', this.toggleDraggingOverDocument );
window.addEventListener( 'mouseup', this.resetDragState );
},

componentDidUpdate: function( prevProps, prevState ) {
Expand All @@ -60,9 +61,18 @@ module.exports = React.createClass( {
window.removeEventListener( 'drop', this.onDrop );
window.removeEventListener( 'dragenter', this.toggleDraggingOverDocument );
window.removeEventListener( 'dragleave', this.toggleDraggingOverDocument );
window.removeEventListener( 'mouseup', this.resetDragState );
this.disconnectMutationObserver();
},

resetDragState: function() {
if ( ! ( this.state.isDraggingOverDocument || this.state.isDraggingOverElement ) ) {
return;
}

this.setState( this.getInitialState() );
},

toggleMutationObserver: function() {
this.disconnectMutationObserver();

Expand Down

0 comments on commit 74d26d7

Please sign in to comment.