Reorderable icon indicating copy to clipboard operation
Reorderable copied to clipboard

Dragged item snaps back if the list is modified while it's dragged and the item would move out of the composition.

Open Nek-12 opened this issue 3 months ago • 5 comments

  1. Make two lists: [1, 2, 3, 10], and [1,2,3,4,5,6,7,8,9,10], and be sure to assign keys. Note: no more than 5 items should be on screen at the same time in that case, such that you have to scroll more than 3 items to reach the end.
  2. Grab item 10 from the first list, like this: [1, 2, 3, <10>]
  3. In response to isAnyItemDragged, recompose the LazyColumn with the second list: [1,2,3,4,5,6,7,8,9,<10>]
  4. For one-two frames, the item 10 ends up out of the LazyColumn's visible item list.
  5. The dragged item goes out of the composition, the dragged state resets for the item, the item snaps back to its original position, isAnyItemDragged becomes false, and the list snaps back to [1,2,3,10] (no item dragged now).

To solve this, we need to persist the dragged item under the finger and its drag state, even if it would go out of composition when it became dragged (because the item was under the finger the whole time, it should stay on screen).

My use-case is that I want to reorder a list of items, where some items are hidden until I start reordering. For a brief moment during the gesture, the items must appear as soon as I start a drag, and disappear when I finish it.

Nek-12 avatar Sep 04 '25 13:09 Nek-12

any idea how to persist a composition even after the item scrolls off screen? it's been a problem from the beginning and the source of a lot of issues and headaches.

the main thought is that I don't want to call a composition twice such that any side effects inside will be called twice.

Calvin-LL avatar Sep 04 '25 17:09 Calvin-LL

The only way I know is movableContentOf which essentially is a remembered composition.

Nek-12 avatar Sep 04 '25 17:09 Nek-12

amazing. thank you for all the issues btw!

Calvin-LL avatar Sep 04 '25 17:09 Calvin-LL

Well thank you for the library Calvin! This is the only maintained library that works relatively well for reordering items! Our app heavily relies on it.

Nek-12 avatar Sep 04 '25 19:09 Nek-12

I also want to say thank for the library, it is pretty amazing and I would also like to upvote this issue, because I have been struggling with this one in my app. Thanks

pAlkesz avatar Sep 17 '25 09:09 pAlkesz