react-select icon indicating copy to clipboard operation
react-select copied to clipboard

Drag to reorder

Open wmertens opened this issue 11 years ago • 29 comments

Would be very nice to have. The Angular UI-Select has it :grin: https://github.com/angular-ui/ui-select/blob/6e81746d31cb8e5fda8f6b9eed066d9a2e6ba4c1/src/uiSelectSortDirective.js

wmertens avatar Mar 12 '15 22:03 wmertens

+1

atran avatar Mar 27 '15 21:03 atran

Keen. Will need some time to get around to adding it, PRs welcome.

JedWatson avatar Mar 31 '15 23:03 JedWatson

+1

bkniffler avatar Aug 06 '15 14:08 bkniffler

+1

sriprabha avatar Sep 10 '15 23:09 sriprabha

+1

solognt avatar Jan 05 '16 10:01 solognt

I created a little fiddle based on the react-select html and the html5 sortable by RubaXa (https://github.com/RubaXa/Sortable).

https://jsfiddle.net/oqjqgbpb/6/

On sort end it gives me the old and new index of the element so I can update the collection and re-render the selector.

This seems to work fine on the html alone but when I use it directly on the react-select element drag/drop does not work any-more. I seems the selector blocks the necessary events somewhere.

Any pointers would be welcome..

solognt avatar Jan 20 '16 13:01 solognt

Hi @solognt, i'm looking to solve this problem as well. Any progress? Happy to review your work / collaborate.

dcworldwide avatar Jan 24 '16 01:01 dcworldwide

+1any more updates?

sumitk avatar Apr 28 '16 20:04 sumitk

i've been thinking about implementing this using react-dnd. Sound good?

rich-b avatar Jul 25 '16 18:07 rich-b

Introducing a dependency for such a small feature seems overkill, especially since native html5 dnd isn't hard to implement, and might even be easier in this specific case.

bkniffler avatar Jul 26 '16 06:07 bkniffler

+1

turnerniles avatar Aug 22 '16 18:08 turnerniles

@rich-b: i've been thinking about implementing this using react-dnd. Sound good?

I'd also suggest checking out react-sortable-hoc. It's really slick.

IMO this functionality (drag-and-drop re-ordering) is a bit more complicate than belongs in the base react-select library. (This library is primarily owned and maintained by Jed- an individual. It doesn't have a full team behind it like angular-ui. So limiting the scope and ambition of this project will help keep it easier for him to maintain.)

I believe this functionality should already be possible by supplying a custom menuRenderer and using react-sortable-hoc inside of it.

bvaughn avatar Sep 04 '16 05:09 bvaughn

I managed to integrate react-dnd with react-select without any changes to latter one. Gist is here. Let me know what do you think!

krzysu avatar Oct 19 '16 13:10 krzysu

@krzysu Did you try that on the 1.0 branch? It doesn't seem to work for me.

davidworkman9 avatar Apr 24 '17 14:04 davidworkman9

@davidworkman9 no, I didn't, I haven't touched it since my last post. I have no idea about changes in 1.0 branch, you need to figure it out by yourself, sorry :)

krzysu avatar Apr 24 '17 14:04 krzysu

Thanks, just checking as the 1.0 branch was out in October. I was able to get it to work by adding onValueClick={() => {}} to the props to react-select.

davidworkman9 avatar Apr 24 '17 18:04 davidworkman9

#1720

songyanho avatar May 12 '17 04:05 songyanho

@bvaughn I had the same thought re: react-sortable-hoc, here's a gist. I pulled out mobx code, so possible it doesn't work out of the box.

The only real hacky bit was extracting the index in valueComponent, so if that prop was to come through to the supplied component, vanilla react-sortable-hoc components would be a go.

aschmoe avatar Jun 27 '17 03:06 aschmoe

Adding a new prop, index, to valueComponent seems reasonable to me. Put together a PR?

bvaughn avatar Jun 28 '17 14:06 bvaughn

I added the index property and also added an example with the sortable-hoc included in this fork. Happy to create a PR if it is wanted.

However, adding the index property is a somewhat arbitrary thing from the perspective of react-select and the working example has some issues such as when the ordering extends over multiple lines or with the styling of the element being dragged.

pwhipp avatar Sep 25 '17 01:09 pwhipp