-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
MultiDrag: Simultaneous multiselection across different lists #2173
Comments
I just discovered this issue myself. Don't know if this is a "bug" or an "enhancement". But it really should be a part of MultiDrag. If anyone wants to implement this, I'd be willing to (co)sponsor development. |
I've created a Code Pen to illustrate this issue: The MultiDrag plugin does not allow you to select items from multiple lists simultaneously. Selecting an item from a 2nd list will unselect previous selections. So items from multiple lists cannot be dragged together. |
I'm not seeing this behavior in my example. |
I've funded a Bountysource listing for a PR on the MultiDrag plugin to add simultaneous multiselection across different lists. |
Thank you for all the input. The described behavior seems to be a wrapper bug limited to the react-sortablejs implementation - I edited the initial post to reflect that. |
FWIW, I think this is going to require some restructuring of MultiDrag's interface MultiDragIndex { // I'm just making up a name for this type
index: number
multiDragElement: HTMLElement
} The problem is that if we allow dragging from multiple Sortable lists at once, then the interface MultiDragIndex {
index: number // now within the parentElement
multiDragElement: HTMLElement // same as before
parentElement: HTMLElement // or maybe sortableElement? indexParent?
} In order to maintain backward compatibility, we'll also probably need a new switch to enable dragging between lists… something like |
This looks like fun, I'll take a gander! |
Couldn't this be accomplished by simply checking wether the multidrag component has a |
It would certainly be cleaner than adding another setting option. I also can't think of a reason why someone would want to maintain the old behavior. If an item CAN be dragged between lists, it should be able to be SELECTED to drag between those lists. 👍 Of course, from a user/browser perspective, there's only one "selection" at a given time. So if items from another |
How would we realistically handle more complex group configurations? Let's say you have three groups (A, B, C) with two sortables each. A1 and A2 can put to B, but only A2 can put to C. Should items from multiple sortables in A be selectable together? |
Whoa! It does get confusing, doesn't it? I didn't realize that SortableJS could get that granular. Individual items within a given Sortable list can be assigned different group pull/put values? Or is this implemented by assigning multiple Sortable instances to the same list? At a certain point, we just need to leave it to the developer not to implement a confusing configuration. But this may be another argument for having a But it does seem like the |
More like multiple sortable lists can be assigned the same group, but with different rules. The following works as expected (without cross-list selection):
There is something taxonomically confusing to me about groups overall, in that any settings that apply to a group for one component (in my opinion) reasonably should apply to all components in that group. As it stands it becomes kind of difficult to reason about the properties of a group, or what membership of a group entails. Speaking of groups, are there any established patterns for finding all Sortable instances in a specific group? Alternatively, to find the element with a Sortable instance that is closest to any arbitrary DOM element? Otherwise I'll try to implement it, just wanted to avoid reinventing the wheel. |
Hmm… I can't figure out how you'd find all instances of Sortable in any group. I'm still trying to get my head around the whole Don't know if I'm being helpful. 🙂 |
Tried to make as non-intrusive a solution as possible. Please take a look when you can :) The way it works:
As long as your group configurations are fairly reasonable, this shouldn't produce any weird results. However, funnily enough, cross-selecting between lists now allow you to resort a list even if it has |
Thanks @maxbol! This is great. I've updated the Code Pen with a patched version of Sortable from your PR. I found a few issues. But I've commented on the pull request. |
Is there any way to simultaneously select multiple items across different lists sharing the same group and drag them (to another one or any of the original lists)?
It seems that, at the moment, multidrag selection is confined to one list at a time, with selected items in one list being deselected if an item in another list is selected.
Edit 27/06 - react-sortablejs v6.1.4 issue: Additionally, when multiple items are dragged to a different list, the selection seemingly disappears on drag end. However, by selecting a few items of the target list immediately after, the selection size includes the previous items which then cause a crash on drag end (still inside the target list).
The text was updated successfully, but these errors were encountered: