mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 00:19:55 +03:00
Fix handling drag
This commit is contained in:
parent
eb4f461522
commit
dadad2d95b
|
@ -115,10 +115,20 @@ export default function ActionList<A extends Action<unknown>>({
|
||||||
const handleDragEnd = useCallback(
|
const handleDragEnd = useCallback(
|
||||||
({ active, over }: DragEndEvent) => {
|
({ active, over }: DragEndEvent) => {
|
||||||
if (over && active.id !== over.id) {
|
if (over && active.id !== over.id) {
|
||||||
onReorderAction(active.id as number, over.id as number);
|
const activeIndex = actionIds.indexOf(active.id as number);
|
||||||
|
const overIndex = actionIds.indexOf(over.id as number);
|
||||||
|
|
||||||
|
const beforeActionId =
|
||||||
|
overIndex < activeIndex
|
||||||
|
? (over.id as number)
|
||||||
|
: overIndex < actionIds.length - 1
|
||||||
|
? actionIds[overIndex + 1]
|
||||||
|
: actionIds.length;
|
||||||
|
|
||||||
|
onReorderAction(active.id as number, beforeActionId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[onReorderAction],
|
[actionIds, onReorderAction],
|
||||||
);
|
);
|
||||||
|
|
||||||
const lowerSearchValue = searchValue && searchValue.toLowerCase();
|
const lowerSearchValue = searchValue && searchValue.toLowerCase();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user