question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible to combine sortables?

See original GitHub issue

I’m trying to use dnd-kit on a board where cards can be reordered and combined, similar to this example from react-beautiful-dnd.

Is this possible to do using the current @dnd-kit/sortable package? I can probably do it with @dnd-kit/core but I assume I’d miss out on things like keyboard sorting and sorting strategies.

Any thoughts/guidance would be much appreciated!

This library is awesome by the way 😁

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
claudericcommented, Mar 3, 2021

This should be possible yes, you’ll need to put in a bit of work though.

Say you were building a vertical list, I’d start by forking the verticalListSortingStrategy and updating the threshold after which a node should shift positions.

You’d also need to update the onDragEnd handler to either combine the items if dropped within the given threshold or reorder thee items.

If you want to support keyboard input, you would also need to fork the keyboard coordinates getter to first move into the threshold that doesn’t cause the node to shift position on the first keydown event, and then outside of that threshold on the second keydown event.

2reactions
awgvcommented, Jul 25, 2022

I’ve been looking for workarounds and found a pattern that’s a bit weird in terms of user experience, but I’ve decided to give it a go nonetheless—sharing a rough sketch of how it might look like in case somebody finds it useful (my use-case is an extension of the pointerWithin). You basically divide each item in a vertical list in half; the left side always sorts, and the right side always combines:

https://user-images.githubusercontent.com/6409354/165963684-2cbeadbe-e49c-4fe0-9d18-1aa199e915bc.mp4

Read more comments on GitHub >

github_iconTop Results From Across the Web

Combining jQuery draggable, droppable, and sortable
I'm trying to combine jQuery draggable, droppable, and sortable; however, I keep having problems. Can anybody help me? Basically, the idea is illustrated ......
Read more >
combine selectable and sortable
is it possible to combine the selectable with the sortable ui? i dont think so but maybe someone has discovered this already
Read more >
Sortable Widget | jQuery UI API Documentation
If defined, the items can be dragged only horizontally or vertically. Possible values: "x" , "y" . Code examples: Initialize the sortable with...
Read more >
jQuery Sortable
Why another sortable plugin? you might ask. Aren't there many others? The answer is: nested lists. None of the other solutions had a...
Read more >
Make one Sortable to connectWith multiple ...
Please advise, If this approach is possible and supported in Kendo UI Sortable. If yes, please kindly provide a working example. Thank you....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found