Skip to content

Managing state when moving items between lists #23

Closed
@nlhkabu

Description

@nlhkabu

Thanks again for this lib.

I have several lists on my page, and want to be able to drag items between lists. For this, I give every list the same sortable group option.

This is how I am trying to manage the state when dragging an item between lists:

  1. use remove event to remove item from the state
  2. use add event to add the item back to the state in its new location

My state is updating just fine, however, the orginal DOM element is moved to the new list (and not removed from the DOM). This results in duplicates (because my state also creates a new element).

Currently, it looks like my options are to either:

  1. manually remove the DOM element with event.item.remove() OR
  2. force re-render my component to keep the state in sync

Both of these seem hacky - is there a better approach?

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