-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dragEndAction is not called on successful drop #118
Comments
|
Sorry mis-read your comment. It should be working as intended. It should fire on a successful drop. |
Appears to be working in this demo -> http://mharris717.github.io/ember-drag-drop/#/simple |
Thanks for the reply! |
To confirm: it does seem to be something within my drop handler that is causing the problem: when I change the drop handler to return immediately, |
If a drop action causes the draggable component instance to be destroyed, the dragEnd event isn't fired, resulting in the dragCoordinator being left in an inconsistent state (it thinks the object is still being dragged). This change ensures the dragCoordinator state gets cleaned up before the draggable-object is destroyed. Note that this fix still won't result in the dragEndHook or dragEndAction being fired: both of them are still only triggered if a browser dragEnd event fires. It's not clear if they can be caused to fire in this case without breaking the API, since both take the dragEnd event as a parameter, which doesn't exist in this case. This seems fine for dragEndHook, since it appears to mostly be used for DOM changes/cleanup and this section of the DOM is going away, but it feels a bit strange that dragEndAction wouldn't be fired. Two possible options: - send dragEndAction without an event - add a new "dragFinally" action that gets called in both cases Related to mharris717#118
I've confirmed that the problem occurs when a drop handler causes a data change that in turn causes the dropped draggable-object component to be destroyed. It seems this happens because the browser In any case, you can play with a MCVE here: https://ember-twiddle.com/155776d5af6dd8b662fea9a914921329 and I've submitted a PR that fixes my (that) immediate problem: #119 (it wasn't really obvious that this was the problem from my usage, because in my case i'm actually just re-arranging the underlying data, not removing anything entirely, so it took some ember-inspector-ing to realize that the updated underlying data structure was causing the component to be removed in one place and re-created in another) |
I'm afraid your PR might break |
It seems that
dragEndAction
is only called when the drag ends unsuccessfully (ie not on a drop target), and dragCoordinator.currentDragObject is only updated in these cases too. This seems to mean that there's no straightforward way to track whether an object is actually currently being dragged.Is this intended behavior? Is there some other way to know if a drag is in-progress?
In case it's relevant, I'm running Chromium Version 62.0.3202.94 (Official Build) Built/Running on Ubuntu
The text was updated successfully, but these errors were encountered: