fix: simplify drag-and-drop logic in ListsScreen and ManageColumnsDialog for reordering items

This commit is contained in:
2025-10-26 15:29:33 +01:00
parent 9e70fcb28a
commit 9b1cbccd03
2 changed files with 2 additions and 7 deletions
@@ -2515,9 +2515,7 @@ fun ManageColumnsDialog(
) { ) {
if (from == to) return if (from == to) return
if (isEmpty() || from !in indices) return if (isEmpty() || from !in indices) return
val item = removeAt(from) add(to.coerceIn(0, size), removeAt(from))
val insertIndex = (if (to > from) to - 1 else to).coerceIn(0, size)
add(insertIndex, item)
} }
val reorderState = val reorderState =
@@ -161,10 +161,7 @@ fun ListsScreen(
) { ) {
if (from == to) return if (from == to) return
if (isEmpty() || from !in indices) return if (isEmpty() || from !in indices) return
val item = removeAt(from) add(to.coerceIn(0, size), removeAt(from))
// When moving downwards, the target index shifts left by one after removal
val insertIndex = (if (to > from) to - 1 else to).coerceIn(0, size)
add(insertIndex, item)
} }
val reorderState = val reorderState =