-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Open
Description
I deleted a lot of items. Then I moved some items up. However the items that were moved were not the items I had selected, they were the items I had deleted and they came back again
I using react and sortablejs@1.15.7
const updatePosition = () => {
if (!sortableRef.current) return
let ids = sortableRef.current.toArray()
setImages((images) => {
return sortBy(images, [
(image) => {
const index = ids.findIndex((id) => Number(id) === Number(image.id))
return typeof index === 'number' ? index : 9999
},
])
})
}
useEffect(() => {
updateFormikField()
if (typeof setOuterPhotos === 'function') {
setOuterPhotos(images)
}
if (isSingle) return
if (!sortableRef.current && !viewMode) {
sortableRef.current = new Sortable(sortableEleRef.current, {
multiDrag: true,
selectedClass: 'sortable-selected',
onEnd: updatePosition
})
}
updatePosition()
}, [images.map((o) => o.id).join(',')])Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels