bevacqua / dragula

:ok_hand: Drag and drop so simple it hurts
https://bevacqua.github.io/dragula/
MIT License
22.08k stars 1.97k forks source link

cancel event does not fired when copy: true #684

Open PFight opened 3 years ago

PFight commented 3 years ago

Please only use GitHub issues for bug reports and feature requests.

  • [x] Read the contributing guidelines
  • [x] Bug reports containing repro steps are likely to be fixed faster
  • [x] Feature requests should be multi-purpose, describe use cases
  • [x] For support requests or questions, please refer to our Slack channel

Repro steps: 1) Open second sample on https://bevacqua.github.io/dragula/ (with events) 2) Change dragula([$('left-events'), $('right-events')]) to dragula([$('left-events'), $('right-events')], { copy: true }), and add subscription to 'cancel' event 3) Try to drag last item in the left column bit lower in bounds of its container and release - no cancel event raised

Reason: _copy is not in the dom, so getParent(_copy) returns null, and then isInitialPlacement returns false, and we go to drake.emit('drop', item, null.

image

Because of this bug there is no way to distinguish two situations: 1) Item was moved out of the container 2) Item moved inside the container

In the second case we should get 'cancel' event, but actually, in both cases we get 'drop" event with target = null.

PFight commented 3 years ago

Fixed in temporary package dragula-fixed