Calvin-LL / Reorderable

Reorder items in Lists and Grids in Jetpack Compose and Compose Multiplatform with drag and drop.
Apache License 2.0
508 stars 17 forks source link

Drag and drop releases randomly on large items #57

Open RicardasBivainis opened 2 weeks ago

RicardasBivainis commented 2 weeks ago

So this issue post compose update to 1.7.0. When trying to drag large items somehow it releases automaticly and drops randomly.

In video I use:

I used other resolutions for testing and the same bug appears.

Screen_recording_20241106_080151.webm

Screen_recording_20241106_080015.webm

image

Calvin-LL commented 2 weeks ago

What's the version of compose in your project and which version of this library are you using?

RicardasBivainis commented 2 weeks ago

It's your demo project:

activityCompose = "1.9.3" agp = "8.3.2" compose = "1.7.0" kotlin = "2.0.0" mavenPublish = "0.29.0" precompose = "1.6.1" uiTooling = "1.7.5"

group = "sh.calvin.reorderable" version = "2.4.0"

RicardasBivainis commented 2 weeks ago

It seems that the main thing is the size (or maybe zoom(display item size maximization))

Calvin-LL commented 2 weeks ago

Hmm I'll take a look. I thought it was solved already

RicardasBivainis commented 2 weeks ago

Sorry last issue that I opened just did not have time at that moment to provide more information. My bad.

RicardasBivainis commented 2 weeks ago

Hey, did you managed to reproduce the issues? Any update?

Calvin-LL commented 2 weeks ago

It's a busy week. I'll try to take a deeper look soon. It's not immediately obvious in the code what's wrong.

bkonrad-check commented 5 days ago

We got the same issue. Happens also with the sample project, if you do this:

package sh.calvin.reorderable.demo

data class Item(val id: Int, val text: String, val size: Int)

val items = (0..200).map {
    Item(id = it, text = "Item #$it", size = if (it % 2 == 0) 70 else if(it == 15) 1000 else 100)
}

Debugged it a big, it seems like in fun Modifier.draggable for some reason the DisposableEffect is called and then everything is getting cleared. Maybe some behavior changes in the new compose version?

Did you maybe get some insights @Calvin-LL?

Calvin-LL commented 5 days ago

So the problem is the dragging item's actual position on the list can't be moved off screen. Once it's moved off screen, LazyColumn disposes it. I had something in the stroller to make sure a dragging item is never scrolled off screen but I'm not sure why it's not working. I'll have to wait till I have a free day to take a deeper look. Feel free to dig into it and see if you can solve it.