Reputation: 295
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
Reputation: 1820
This worked for me,
<Sortable
options={{disabled:true, ...}} > ...
Upvotes: 0
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