Skip to content

Commit

Permalink
fix: dnd freezes an event intermittently (#1631)
Browse files Browse the repository at this point in the history
* Fixed an issue where dnd freezes an event intermittently

* Make sure OnEnd is called no matter if it's being dragged
  • Loading branch information
zheyujie committed Apr 9, 2020
1 parent c31639a commit e8609af
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/addons/dragAndDrop/EventContainerWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class EventContainerWrapper extends React.Component {

_selectable = () => {
let node = findDOMNode(this)
let isBeingDragged = false
let selector = (this._selector = new Selection(() =>
node.closest('.rbc-time-view')
))
Expand Down Expand Up @@ -177,16 +178,22 @@ class EventContainerWrapper extends React.Component {
this.handleDropFromOutside(point, bounds)
})

selector.on('selectStart', () => this.context.draggable.onStart())
selector.on('selectStart', () => {
isBeingDragged = true
this.context.draggable.onStart()
})

selector.on('select', point => {
const bounds = getBoundsForNode(node)

isBeingDragged = false
if (!this.state.event || !pointInColumn(bounds, point)) return
this.handleInteractionEnd()
})

selector.on('click', () => this.context.draggable.onEnd(null))
selector.on('click', () => {
if (isBeingDragged) this.reset()
this.context.draggable.onEnd(null)
})

selector.on('reset', () => {
this.reset()
Expand Down

0 comments on commit e8609af

Please sign in to comment.