Cancel drag or disable reorder

Viewed 3392

Is there a way to cancel drop action of react-beautiful-dnd's Draggable object? I have a list of items with one item to be always at last position. enter image description here

I want to disable (or at least properly cancel) drop if item is dragged below last item. I know I can exclude last item from droppable component and area, but that's not an option.

1 Answers

It is simple

When you drop any element in the onDragEnd method you'll get an object for destination and source so in that destination you find one index.

This index is referred to as your element at that index in your list of elements.

So you can make one condition there like if your element list length is equal to your index then don't do nothing return from that function.

Related