Skip to main content

Search and Top Navigation

#9756 closed feature (wontfix)

Opened January 20, 2014 08:47PM UTC

Closed May 20, 2014 02:48PM UTC

Sortable: Allow calling refresh during drag

Reported by: NiGhTTraX Owned by: NiGhTTraX
Priority: minor Milestone: none
Component: ui.sortable Version: 1.10.4
Keywords: Cc:
Blocked by: Blocking:
Description

If you remove an item from a sortable while sorting and then call the

 refresh 
method it will cause the
 change 
event to fire at every mouse drag.

See this http://jsfiddle.net/NiGhTTraX/6mdZN/ for more details. When you start sorting the list, or drag a draggable over, the

 sortover 
event will fire. In the event function, I remove the last element in the list and call
 refresh 
. Notice that the
 change 
event is logged in the console on every mouse drag.

The problem seems to be in the

 _mouseDrag 
function. More specifically, the event is triggered at line 406.

Attachments (0)
Change History (7)

Changed January 20, 2014 09:41PM UTC by tj.vantoll comment:1

owner: → NiGhTTraX
status: newpending

Do you have a practical use case for this behavior? Removing an item from the list on hover seems like bad UX.

Changed January 21, 2014 05:15AM UTC by NiGhTTraX comment:2

status: pendingnew

Use case: I'm building a sortable with a max size. When the list gets full and you drag a new item, the last existing item is removed.

The workaround would be to hide the item and remove it on

 sortstop 
, but I thought this behaviour deserved an issue so the
 refresh 
method could be looked into.

Changed January 21, 2014 03:26PM UTC by tj.vantoll comment:3

Removing an item when the user starts dragging seems odd and potentially disorienting to the user. I'll wait for the opinion of someone else on the team though.

Changed May 20, 2014 02:16AM UTC by petersendidit comment:4

I agree with TJ, removing the item when the user drags and item is a very bad user experience. By using the over event it doesn't care if the item is new or not, you could be dragging an item that is already in the list and just resorting them, in your demo this is a problem, just try to drag number 3. Seems like what you really should do is be using the 'receive' event.

Changed May 20, 2014 08:49AM UTC by NiGhTTraX comment:5

I've implemented a logic to tell if the item is new or not but I didn't include it in the demo to not over-complicate it. Assuming that, my primary use case is to delete an item from the destination sortable to make room for an incoming item.

Changed May 20, 2014 08:58AM UTC by NiGhTTraX comment:6

And the receive event is triggered when you drop a new item. I need to make room for it as soon as it's over the list.

Changed May 20, 2014 02:48PM UTC by tj.vantoll comment:7

resolution: → wontfix
status: newclosed
summary: Removing an item and calling refresh during drag causes weird event behaviorSortable: Allow calling refresh during drag
type: bugfeature

This is more of a feature request than a bug, because refresh was never intended to be called during a drag, at least that I'm aware of. Since this has not been requested before, I'm going to close this ticket for now. If others desire this functionality, please add a comment to this ticket and we can consider it for the rewrite.