8000 [comp] adds error handlig for onSelect just incase value are -1 · dasveloper/react-sortablejs@d2f4751 · GitHub
[go: up one dir, main page]

Skip to content

Commit d2f4751

Browse files
author
Wayne Van Son
committed
[comp] adds error handlig for onSelect just incase value are -1
1 parent 7703081 commit d2f4751

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/react-sortable.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
311311
const newList = [...list].map(item => ({ ...item, selected: false }));
312312
evt.newIndicies.forEach(curr => {
313313
const index = curr.index;
314+
if (index === -1) {
315+
console.log(
316+
`"${evt.type}" had indice of "${curr.index}", which is probably -1 and doesn't usually happen here.`
317+
);
318+
console.log(evt)
319+
return
320+
}
314321
newList[index].selected = true;
315322
});
316323
setList(newList, this.sortable, store);

0 commit comments

Comments
 (0)
0