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
Add ability to escape/cancel out of dragging once started #14
Add ability to escape/cancel out of dragging once started #14
Conversation
Thanks for the PR, @oscarssanchez! This unfortunately does not seem to work for me - it does cancel the drag in the UI but it still gets updated to the position where you dropped it, which you can then see on a refresh. I see a spinner briefly as well which tells me that the |
Hi @helen, You were right, the update method was still running. I just modified the file so it now stops the updating method if ESC is pressed. |
@oscarssanchez I'm a little bogged down at the moment, so I'm going to kick this over to my coworker @dkotter for more timely review and feedback this week. Thanks for staying on top of this! |
Hey @oscarssanchez, thanks for the work here. Testing this out, it does seem to work for me but I do think there are a few things that can be cleaned up/changed up a bit.
And finally, in my testing, the proper way to stop sorting is by using There's a method to set an option and it's value that I think would work. Within the escape key function, I'd recommend we do something like Then within the Let me know if this all makes sense or if you have any questions. Happy to expand further as needed. Thanks! |
3dd1c5b
to
6635dca
Compare
6635dca
to
9c7d312
Compare
@oscarssanchez Hey there - we're still interested in getting this feature into a future release, so if you're unable to keep going with this PR for whatever reason, let me know and we'll take it from here. Thanks! |
Hi @helen, I'm sorry about the confusion, I made some mistakes while updating my branch and I ended up erasing my previous commits due to a force push, hence the PR closed automatically. It seems like it's fine now. Thanks! And sorry about that. |
Hi @dkotter, Thank you for your very detailed feedback. Your suggestion is great. I was talking about it with someone and he also suggested solving the problem by adding/removing classes may not have been the best approach. In my testing with this approach however, setting From what I read in the documentation, you can add new options and set some values with the That way, the sortable still prevents updating while dragging and does not disable the sorting functionality if the user presses ESC by accident while not dragging a page. I'm not sure if it may be a good solution, i'll be glad to read more feedback. Thanks! |
@oscarssanchez Just tested this out and it works great, thanks for this! And good catch on the use case of someone using the escape key while not in the process of dragging. Using a custom option there is a much better solution. I've left two minor CR items that would be nice to add and then if you could, we serve the minified version of the JS file unless the Thanks again for the help here, looking forward to getting this merged in. |
Hi @dkotter, I'm not too familiar with the last step, but no problem I could do it. However, i'm not sure if what you need is the compiled src file or you are going to make some changes before and then compile it. I wanted to check first. |
@oscarssanchez I wasn't planning on making any changes, so when you run the compile step, it will compile the src file you've modified to the minified version. Again, I'm happy to run this step as well, if you'd prefer. If so, I think we're good to go here and I can merge this in. |
@@ -88,10 +97,17 @@ sortable_post_table.sortable({ | |||
return ui; | |||
}, | |||
stop: function(e, ui) { | |||
if ( sortable_post_table.sortable( 'option', 'preventUpdate') ) { | |||
sortable_post_table.sortable( 'option', 'preventUpdate', false ); | |||
} | |||
// remove fixed widths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oscarssanchez Can you add a line break here, just so these sections of code are a little more separated?
if ( sortable_post_table.sortable( 'option', 'preventUpdate') ) { | ||
sortable_post_table.sortable( 'option', 'preventUpdate', false ); | ||
return; | ||
} | ||
sortable_post_table.sortable('disable').addClass('spo-updating'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oscarssanchez Can you add a line break here, just so these sections of code are a little more separated?
Hey @dkotter, I just made the changes. |
@oscarssanchez Thanks! Just tested it out and it works great for me. I've compiled that JS file and pushed to your branch. Assigning this over to @helen for final review and merge. |
This looks great! Nice work, all. I'll get this merged and look at the other PR to see if we can do a new release soon. |
Hi @helen
Would this work to solve #12 ?
The functionality works as requested, however, i'm not sure if the code could better fit elsewhere.