Skip to content
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

Dropped event is fired on cancellation #34

Open
ostrichglue opened this issue Jan 8, 2019 · 4 comments
Open

Dropped event is fired on cancellation #34

ostrichglue opened this issue Jan 8, 2019 · 4 comments

Comments

@ostrichglue
Copy link

I have a list of items that I need to update on the server when a reorder is performed. To do this I hook into the dropped event and perform an ajax call . However, it appears that the dropped event fires even when a user cancels the re-order with esc. Is this intended functionality?

@ostrichglue ostrichglue changed the title Reorder event is fired on cancellation Dropped event is fired on cancellation Jan 8, 2019
@schne324
Copy link
Owner

schne324 commented Jan 8, 2019

It was intended originally but I'm now thinking it'd be useful to add support for a new "cancelled" event and fire that rather than dropped.

What do you think about that?

@ostrichglue
Copy link
Author

ostrichglue commented Jan 8, 2019

That would be great, right now I'm using a "Save Changes" button since I don't have a reliable way to know if the user canceled the action or actually dropped the item. However, I am a bit confused because it looks like there is a cancel event already according to the docs.

image

I tested hooking into that event as well as the dropped and confirmed that both dropped and canceled are fired when the user cancels the action.

@schne324
Copy link
Owner

schne324 commented Jan 9, 2019

Ah right. I completely forgot about the cancel event. Sounds like the bug here is that the dropped event is emitted when cancel takes place.

sfisher added a commit to datadryad/dryad-app that referenced this issue Apr 6, 2022
@sfisher
Copy link

sfisher commented Apr 6, 2022

I ran into this issue, also. Unfortunately, the "cancel" seems to trigger after the "dropped" event and with a new order as if it had been reordered. If it triggered before then an easier workaround would be to ignore the "dropped" event immediately following a "cancel" event.

We are also updating ordering to the server by AJAX/json, so I put a very hacky workaround in that saves the original order before reordering of the "dropped" event and then if a cancel event happens it makes a slightly delayed request that re-updates back to the original order to overwrite bad order from the extra "dropped" event. Our UI design doesn't have submit buttons.

The cancel problem only happens when using the keyboard to reorder, afaik. While the display reverts correctly on a pressing the escape key to cancel the data present at the drop event looks like something got moved. It would be nice if the "dropped" trigger never fired at all since the user never completed the action or intended a drop if they hit escape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants