Skip to content

Commit

Permalink
fixes: #38
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hutchison committed Feb 11, 2015
1 parent fc4c7d2 commit 2404d35
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions modules/mixins/DragDropMixin.js
Expand Up @@ -14,7 +14,6 @@ var DragDropActionCreators = require('../actions/DragDropActionCreators'),
assign = require('react/lib/Object.assign'),
defaults = require('lodash/object/defaults'),
union = require('lodash/array/union'),
rest = require('lodash/array/rest'),
without = require('lodash/array/without'),
isArray = require('lodash/lang/isArray'),
isObject = require('lodash/lang/isObject'),
Expand Down Expand Up @@ -56,12 +55,12 @@ function checkDropTargetDefined(component, type) {
);
}

function callDragDropLifecycle(func, component) {
if (component.constructor._legacyConfigureDragDrop) {
return func.apply(component, rest(arguments, 2));
function callDragDropLifecycle(func, component, ...rest) {
if (component && component.constructor._legacyConfigureDragDrop) {
return func.apply(component, rest);
}

return func.apply(null, rest(arguments, 1));
return func.apply(null, [component].concat(rest));
}

var UNLIKELY_CHAR = String.fromCharCode(0xD83D, 0xDCA9),
Expand Down Expand Up @@ -312,23 +311,26 @@ var DragDropMixin = {
HTML5.endDrag();

var { endDrag } = this._dragSources[type],
effect = DragDropStore.getDropEffect();
effect = DragDropStore.getDropEffect(),
mounted = this.isMounted();

DragDropActionCreators.endDragging();

if (!this.isMounted()) {
// Note: this method may be invoked even *after* component was unmounted
// This happens if source node was removed from DOM while dragging.

// Note: this method may be invoked even *after* component was unmounted
// This happens if source node was removed from DOM while dragging.

return;
if (mounted) {
this.setState({
ownDraggedItemType: null
});
}

this.setState({
ownDraggedItemType: null
});

callDragDropLifecycle(endDrag, this, effect, e);
callDragDropLifecycle(
endDrag,
(mounted || this.constructor._legacyConfigureDragDrop) ? this : null, // Don't send static api component if it's unmounted
effect,
e
);
},

dropTargetFor(...types) {
Expand Down

0 comments on commit 2404d35

Please sign in to comment.