Skip to content

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

@Nek-12

Description

@Nek-12
  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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions