fix: adjust drag-and-drop logic in ListsScreen and ManageColumnsDialog to correctly map Lazy positions to data indices
This commit is contained in:
+5
-3
@@ -2527,8 +2527,10 @@ fun ManageColumnsDialog(
|
|||||||
val reorderState =
|
val reorderState =
|
||||||
rememberReorderableLazyListState(
|
rememberReorderableLazyListState(
|
||||||
onMove = { from, to ->
|
onMove = { from, to ->
|
||||||
// Use the same semantics as on the Lists screen for consistency
|
// Map from Lazy positions (including dividers) to data indices
|
||||||
reorderedFields.move(from.index, to.index)
|
val fromData = from.index / 2
|
||||||
|
val toData = to.index / 2
|
||||||
|
reorderedFields.move(fromData, toData)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -2539,7 +2541,7 @@ fun ManageColumnsDialog(
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.reorderable(reorderState),
|
.reorderable(reorderState),
|
||||||
state = reorderState.listState,
|
state = reorderState.listState,
|
||||||
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 16.dp),
|
contentPadding = PaddingValues(vertical = 16.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(0.dp),
|
verticalArrangement = Arrangement.spacedBy(0.dp),
|
||||||
) {
|
) {
|
||||||
// Interleave dividers as separate Lazy items so dividers don't move with dragged rows
|
// Interleave dividers as separate Lazy items so dividers don't move with dragged rows
|
||||||
|
|||||||
@@ -179,7 +179,10 @@ fun ListsScreen(
|
|||||||
onMove = { from, to ->
|
onMove = { from, to ->
|
||||||
dragging = true
|
dragging = true
|
||||||
val newList = working.toMutableList()
|
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
|
working = newList
|
||||||
},
|
},
|
||||||
onDragEnd = { _, _ ->
|
onDragEnd = { _, _ ->
|
||||||
@@ -194,7 +197,7 @@ fun ListsScreen(
|
|||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.reorderable(reorderState),
|
.reorderable(reorderState),
|
||||||
state = reorderState.listState,
|
state = reorderState.listState,
|
||||||
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 8.dp),
|
contentPadding = PaddingValues(vertical = 8.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(0.dp),
|
verticalArrangement = Arrangement.spacedBy(0.dp),
|
||||||
) {
|
) {
|
||||||
// Interleave dividers as separate list items so they don't move with dragged rows
|
// Interleave dividers as separate list items so they don't move with dragged rows
|
||||||
|
|||||||
Reference in New Issue
Block a user