user17443811
user17443811

Reputation: 165

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

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?

Upvotes: 5

Views: 1699

Answers (1)

Werthis
Werthis

Reputation: 1117

You can get isDragging from

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

or

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

and then

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

Upvotes: 7

Related Questions