Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support payload field inside Droppable that is sent to DropResult #2651

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

harisrozajac
Copy link

@harisrozajac harisrozajac commented Jun 26, 2024

Hey I love this library!

In this PR I'm adding a payload that can be passed to Draggable component and then show up in DropResult when onDragEnd is triggered. I have two applications with shared DragDropContext and want to share some data between them by dragging and dropping items. This solution will simplify some custom data sharing and not having to keep a separate state and then doing lookups through draggableId.

Example usage:

<Draggable
     draggableId="id"
     index={0}
     payload={"some data"}
>

The payload would then show up in DropResult like this:

{
    "draggableId": "id",
    "type": "DEFAULT",
    "source": {
        "index": 0,
        "droppableId": "list-app-1",
        "payload": "some data"
    },
    "reason": "DROP",
    "mode": "FLUID",
    "destination": {
        "droppableId": "list-app-2",
        "index": 1
    },
    "combine": null
}

Fixes: #1806

@harisrozajac harisrozajac changed the title Support payload field inside Droppable Support payload field inside Droppable that is sent to DropResult Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

custom source and destination information on onDragEnd
1 participant