From 515f911f54e99556e17d9b60323cc7354f7b5ac9 Mon Sep 17 00:00:00 2001 From: Rikard Tegnander Date: Mon, 21 Aug 2023 09:11:07 +0200 Subject: [PATCH] fix(core): dragging locked segment Fixes: #271 --- packages/core/src/DraggableList/index.tsx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/core/src/DraggableList/index.tsx b/packages/core/src/DraggableList/index.tsx index a8bab5ba..10b67422 100644 --- a/packages/core/src/DraggableList/index.tsx +++ b/packages/core/src/DraggableList/index.tsx @@ -125,13 +125,19 @@ export const DraggableList: FC = ({ const dragIndexRef = useRef() const dropIndexRef = useRef() - const onDragStart = useCallback>(e => { - // Needed for Firefox - // You need to set some data in the dataTransfer member - // of the event when the drag start in Firefox - e.dataTransfer.setData('text', '') - dragIndexRef.current = Number(e.currentTarget.dataset.index) - }, []) + const onDragStart = useCallback>( + e => { + // Needed for Firefox + // You need to set some data in the dataTransfer member + // of the event when the drag start in Firefox + e.dataTransfer.setData('text', '') + const dragIndex = Number(e.currentTarget.dataset.index) + if (locked[dragIndex] !== true) { + dragIndexRef.current = Number(e.currentTarget.dataset.index) + } + }, + [locked] + ) const onDragOver = useCallback>( e => {