Skip to content

Conversation

@codercodingthecode
Copy link

This PR address the documentation for the Sortable Multiselect Component example.
Due to the deprecation of the old Library react-sortable-hoc, recommended the use of the DnD-Kit library.

Included in this PR.

  • Add and use DnD-Kit Library
  • Update documentation for Sortable Multiselect
  • Update the sample array to add an id property
  • Remove the old library.

Address

this issue #5159

Sample using DnD

Kapture 2022-06-01 at 23 47 25

@changeset-bot
Copy link

changeset-bot bot commented Jun 2, 2022

⚠️ No Changeset found

Latest commit: 137c185

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 2, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 137c185:

Sandbox Source
react-codesandboxer-example Configuration

Copy link
Contributor

@Rall3n Rall3n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If dnd-kit is a replacement for react-sortable-hoc, then I would like the example to behave the same as with the latter.

It is currently very restrictive in comparison and cancels the drag if moving too far right.

@immasandwich
Copy link

Got this working to match the existing documentation with the following changes:

  1. Use ValueContainer instead of MultiValueContainer as the droppable area, and ensure that you apply flex-grow: 1 styling to it so it consumes the maximum width of the React Select component.
  2. Use closestCorners as the collision detection algorithm (on the DndContext component)

Thanks for doing most of the leg work!

@dacarmor
Copy link

Hello, how is this matter? Is there any forecast to integrate the changes?

@codercodingthecode
Copy link
Author

I’m no longer using this feature at work. So, I’d like to know if there’s is any interest in moving this forward before I put more of my time into it.
To anyone wanting to contribute, open a pr against current branch and will update here.
I will resolve the current conflicts for now.

@codercodingthecode
Copy link
Author

resolving conflicts after work today.

Andy Lavor added 2 commits January 30, 2023 00:24
# Conflicts:
#	package.json
#	yarn.lock
@codercodingthecode
Copy link
Author

can someone look into the CI Pipeline?

@chrissysemens
Copy link

chrissysemens commented Aug 16, 2023

Hi, I have a few issues trying to use this example:

MultiValue is returning JSX and not components.MultiValue directly and so I receieve a type error:
image

Also, there's a distance prop being passed to Select which is not expected?

image

I understand this has not been merged yet but throught I'd leave the comment as I couldn't see any chance to add a distance prop to select and its not in master, and the typing issue will surface for others?

@NotDemonix
Copy link

I suggest to remove strategy={horizontalListSortingStrategy}, works the same and is better if the component goes into 2 lines.
Next thing to change is transform: CSS.Transform.toString(transform), into transform: CSS.Translate.toString(transform),, this fixes the issue of element width if we have 2 diffrent widths for options. Would open a pr but it doesn't let me.

@NotDemonix
Copy link

distance={4} doesn't seem to be doing anything

@KubaBir
Copy link

KubaBir commented Jul 30, 2025

For anyone looking to use this. There is a problem with using it on mobile which can be resolved by adding
touchAction: 'none' to MultiValue styles

const MultiValue = (props: MultiValueProps<Item>) => {
  const onMouseDown: MouseEventHandler<HTMLDivElement> = (e) => {
    e.preventDefault()
    e.stopPropagation()
  }
  const innerProps = { ...props.innerProps, onMouseDown }
  const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
    id: props.data.value,
  })
  const style = {
    transform: CSS.Translate.toString(transform),
    transition,
    touchAction: 'none',
  }

  return (
    <div style={style} ref={setNodeRef} {...attributes} {...listeners}>
      <components.MultiValue {...props} innerProps={innerProps} />
    </div>
  )
}

https://docs.dndkit.com/api-documentation/sensors/pointer#touch-action

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

Successfully merging this pull request may close these issues.

10 participants