@dnd-kit/sortable : Prevent link from activating when dragged item is dropped

1k Views Asked by At

My sortable item contains a link so when I click on it to drag and drop. Problem is after I drop, it navigates to the link. How can I prevent this?

1

There are 1 best solutions below

0
On BEST ANSWER

You can get isDragging from

const { isDragging } = useDraggable({ id });

or

const { isDragging } = useSortable({ id });

and then

<a href={!isDragging ? 'link' : undefined}>...</a>