Skip to content

Commit e4c6b91

Browse files
authored
allow drop to be cancellable
if hadleDragEnd function returns false, cancel drop
1 parent 8ccfb5d commit e4c6b91

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/components/Lane.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,16 @@ class Lane extends Component {
139139
const {handleDragEnd} = this.props
140140
const {addedIndex, payload} = result
141141
if (addedIndex != null) {
142-
this.props.actions.moveCardAcrossLanes({
143-
fromLaneId: payload.laneId,
144-
toLaneId: laneId,
145-
cardId: payload.id,
146-
index: addedIndex
147-
})
148-
handleDragEnd && handleDragEnd(payload.id, payload.laneId, laneId, addedIndex, payload)
142+
const response = handleDragEnd ? handleDragEnd(payload.id, payload.laneId, laneId, addedIndex, payload) : true
143+
if (response === undefined || !!response) {
144+
this.props.actions.moveCardAcrossLanes({
145+
fromLaneId: payload.laneId,
146+
toLaneId: laneId,
147+
cardId: payload.id,
148+
index: addedIndex
149+
})
150+
}
151+
return response
149152
}
150153
}
151154

0 commit comments

Comments
 (0)