Rohan Naik
Rohan Naik

Reputation: 295

Is there a way to disable sorting in react-sortable--hoc

I have a requirement where the sorting of the list depends on the state which can be toggled using a button. The user should be able to sort only when he is in the editing mode. So I need to disable the sorting of the list. Can anyone help me out on how to add the disabled key to the SortableElement in react-sortable-hoc. I tired to search a working example on google but couldn't find any. Can anyone out there help me out on this one?.

Upvotes: 1

Views: 3397

Answers (2)

Thushara Buddhika
Thushara Buddhika

Reputation: 1820

This worked for me,

<Sortable
    options={{disabled:true, ...}} > ...

Upvotes: 0

Sarhad Salam
Sarhad Salam

Reputation: 438

From reading the documentation, seems like SortableElement supports a disabled flag, you could set the disabled flag to:

<SortableItem ... disabled={editable}/>

Where SortableItem is a wrapper of SortableElement.

If you notice how SortableElement is defined, it just takes config where you can just pass the disabled flag. Hopefully this solves your issue.

Upvotes: 3

Related Questions