aclassen / ComposeReorderable

Enables reordering by drag and drop in Jetpack Compose (Desktop) LazyList & LazyGrid.
Apache License 2.0
821 stars 86 forks source link

Drag Wrong while other item{} exist #252

Closed sinadalvand closed 1 year ago

sinadalvand commented 1 year ago

Consider this code, when you drag item can't detect correct item !

   LazyColumn(
        state = state.listState,
        modifier = Modifier
            .reorderable(state)
            .detectReorderAfterLongPress(state)
    ) {

        item {
              ...
        }

        item {
              ...
        }

        items(data.value, { it.uid }) { item ->
            ReorderableItem(state, key = item.uid) { isDragging ->
                val elevation = animateDpAsState(if (isDragging) 16.dp else 0.dp)
                Column(
                    modifier = Modifier
                        .shadow(elevation.value)
                        .background(MaterialTheme.colors.surface)
                ) {
                        ...
                }
            }
        }
    }
Monabr commented 1 year ago

@sinadalvand so what is the solution?