react-sortable-hoc
react-sortable-hoc copied to clipboard
shouldCancelStart unexpectedly ignored
I have a long press on my sortable component and I don't want sorting to start after the long press. I set shouldCancelStart to true but it DOES start, event though I would expect it to not start.
Simplified example for the purpose of showing the bug:
<SortableContainer
onSortStart={() => this.setState({isSorting: true})}
distance={3}
onSortEnd={(sort) => this.onSortEnd(sort.oldIndex, sort.newIndex)}
shouldCancelStart={() => this.shouldCancelStart}
>
{this.props.views.map((view, index) => {
return (
<SortableItem key={view.id} index={index}>
<div
// This sorts on the first time and on the second time it stops
onMouseDown={() => setTimeout(() =>this.shouldCancelStart = true, 200)
>
{view.caption}
</div>
</SortableItem>
);
})}
</SortableContainer>
Is this wrong usage? If so how can I prevent the sort from starting?
Please help on the same