fix: adjust drag-and-drop logic in ListsScreen and ManageColumnsDialog to correctly map Lazy positions to data indices

This commit is contained in:
2025-10-26 14:35:38 +01:00
parent 168f660446
commit eb5fee1ad2
2 changed files with 10 additions and 5 deletions
@@ -2527,8 +2527,10 @@ fun ManageColumnsDialog(
val reorderState =
rememberReorderableLazyListState(
onMove = { from, to ->
// Use the same semantics as on the Lists screen for consistency
reorderedFields.move(from.index, to.index)
// Map from Lazy positions (including dividers) to data indices
val fromData = from.index / 2
val toData = to.index / 2
reorderedFields.move(fromData, toData)
},
)
@@ -2539,7 +2541,7 @@ fun ManageColumnsDialog(
.fillMaxWidth()
.reorderable(reorderState),
state = reorderState.listState,
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 16.dp),
contentPadding = PaddingValues(vertical = 16.dp),
verticalArrangement = Arrangement.spacedBy(0.dp),
) {
// Interleave dividers as separate Lazy items so dividers don't move with dragged rows
@@ -179,7 +179,10 @@ fun ListsScreen(
onMove = { from, to ->
dragging = true
val newList = working.toMutableList()
newList.move(from.index, to.index)
// Map from Lazy positions (including dividers) to data indices
val fromData = from.index / 2
val toData = to.index / 2
newList.move(fromData, toData)
working = newList
},
onDragEnd = { _, _ ->
@@ -194,7 +197,7 @@ fun ListsScreen(
.fillMaxSize()
.reorderable(reorderState),
state = reorderState.listState,
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 8.dp),
contentPadding = PaddingValues(vertical = 8.dp),
verticalArrangement = Arrangement.spacedBy(0.dp),
) {
// Interleave dividers as separate list items so they don't move with dragged rows