Skip to content

Commit

Permalink
fix(core): dragging locked segment
Browse files Browse the repository at this point in the history
Fixes: #271
  • Loading branch information
Rikard Tegnander authored and Tigge committed Aug 21, 2023
1 parent 1c05957 commit 515f911
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/core/src/DraggableList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,19 @@ export const DraggableList: FC<DraggableListProps> = ({
const dragIndexRef = useRef<number | undefined>()
const dropIndexRef = useRef<number | undefined>()

const onDragStart = useCallback<DragEventHandler<HTMLDivElement>>(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<DragEventHandler<HTMLDivElement>>(
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<DragEventHandler<HTMLDivElement>>(
e => {
Expand Down

0 comments on commit 515f911

Please sign in to comment.