Description
Describe the bug
I have sortable items set up with different class names, including bookend-start
and bookend-end
, and the goal is to keep those items at the start and end of the list respectively. Using the onMove function we return the values shown in the docs to add the item before or after the related object, and while returning false works for cancelling the move, returning either 1 or -1 doesnt seem to have any affect, the dragged item is still dropped in the default direction.
To Reproduce
Steps to reproduce the behavior:
- Create a sortable list with multiple items, including one with a class name like
bookend-end
- Use the following function as the onMove for the sortable list
const relatedClass = e.related.classList
if (relatedClass.contains('sortable-fixed')) {
return false
}
if (relatedClass.contains('bookend-start')) {
return 1
}
if (relatedClass.contains('bookend-end')) {
return -1
} return true
}
- Drag an item around the bookend, the item should still drop on either side, not just the side related to the returned integer
Expected behavior
When we return 1 or -1 to the onMove, the dragged item be added only after or before the related item respectively.
Information
Versions - Look in your package.json
for this information:
"react-sortablejs": "^6.1.4",
"react": "^18.2.0",