react-sortable-hoc icon indicating copy to clipboard operation
react-sortable-hoc copied to clipboard

shouldCancelStart unexpectedly ignored

Open YoavHortman opened this issue 6 years ago • 1 comments

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?

YoavHortman avatar Oct 14 '19 14:10 YoavHortman

Please help on the same

mukesh-kkk avatar Oct 21 '22 10:10 mukesh-kkk