diff --git a/src/containers/costume-tab.jsx b/src/containers/costume-tab.jsx index 5df459150509e96d746bf03aec3fd1671fa6ee6a..8f2717e96e5cb9ef6d6600eff3e29fd84ecb1644 100644 --- a/src/containers/costume-tab.jsx +++ b/src/containers/costume-tab.jsx @@ -206,7 +206,7 @@ class CostumeTab extends React.Component { this.fileInput.click(); } handleDrop (dropInfo) { - if (dropInfo.dragType === DragConstants.COSTUME) { + if (dropInfo.dragType === DragConstants.COSTUME && dropInfo.newIndex !== null) { const sprite = this.props.vm.editingTarget.sprite; const activeCostume = sprite.costumes[this.state.selectedCostumeIndex]; this.props.vm.reorderCostume(this.props.vm.editingTarget.id, diff --git a/src/containers/sound-tab.jsx b/src/containers/sound-tab.jsx index 3df93b1f6039e0945f73d9e804d73b9c11368df1..d8731b4c37ffe3a98847f616a4c4dddbaa478b6e 100644 --- a/src/containers/sound-tab.jsx +++ b/src/containers/sound-tab.jsx @@ -130,7 +130,7 @@ class SoundTab extends React.Component { } handleDrop (dropInfo) { - if (dropInfo.dragType === DragConstants.SOUND) { + if (dropInfo.dragType === DragConstants.SOUND && dropInfo.newIndex !== null) { const sprite = this.props.vm.editingTarget.sprite; const activeSound = sprite.sounds[this.state.selectedSoundIndex]; diff --git a/src/containers/target-pane.jsx b/src/containers/target-pane.jsx index eb41009694069c54b7bc26409fd655e11c844c73..b63a72a3697e6bfabc766dd514684e213287ca72 100644 --- a/src/containers/target-pane.jsx +++ b/src/containers/target-pane.jsx @@ -163,7 +163,7 @@ class TargetPane extends React.Component { } handleDrop (dragInfo) { const {sprite: targetId} = this.props.hoveredTarget; - if (dragInfo.dragType === DragConstants.SPRITE) { + if (dragInfo.dragType === DragConstants.SPRITE && dragInfo.newIndex !== null) { // Add one to both new and target index because we are not counting/moving the stage this.props.vm.reorderTarget(dragInfo.index + 1, dragInfo.newIndex + 1); } else if (dragInfo.dragType === DragConstants.BACKPACK_SPRITE) { diff --git a/src/lib/sortable-hoc.jsx b/src/lib/sortable-hoc.jsx index d3f9c59e14ed37e8fbe5967a265aca0659fa9a97..57087867be93233696db6b338fe3992522a70cb4 100644 --- a/src/lib/sortable-hoc.jsx +++ b/src/lib/sortable-hoc.jsx @@ -33,10 +33,9 @@ const SortableHOC = function (WrappedComponent) { } this.containerBox = this.ref.getBoundingClientRect(); } else if (!newProps.dragInfo.dragging && this.props.dragInfo.dragging) { - const newIndex = this.getMouseOverIndex(); - if (newIndex !== null) { - this.props.onDrop(Object.assign({}, this.props.dragInfo, {newIndex})); - } + this.props.onDrop(Object.assign({}, this.props.dragInfo, { + newIndex: this.getMouseOverIndex() + })); } }