From 417ffe02e5e2b4226a514852dcd3c34c219c9f19 Mon Sep 17 00:00:00 2001 From: harisrozajac Date: Wed, 26 Jun 2024 15:30:08 -0600 Subject: [PATCH 1/2] Support payload field inside Droppable --- .size-snapshot.json | 22 ++++++++++---------- src/state/middleware/drop/drop-middleware.js | 1 + src/types.js | 2 ++ src/view/draggable/draggable-types.js | 1 + src/view/draggable/draggable.jsx | 3 ++- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.size-snapshot.json b/.size-snapshot.json index 424d87419e..15abe2b0e2 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -1,25 +1,25 @@ { "dist/react-beautiful-dnd.js": { - "bundled": 364998, - "minified": 133574, - "gzipped": 39437 + "bundled": 365267, + "minified": 133730, + "gzipped": 39528 }, "dist/react-beautiful-dnd.min.js": { - "bundled": 306810, - "minified": 108365, - "gzipped": 31340 + "bundled": 307035, + "minified": 108499, + "gzipped": 31392 }, "dist/react-beautiful-dnd.esm.js": { - "bundled": 240910, - "minified": 125371, - "gzipped": 32650, + "bundled": 241091, + "minified": 125515, + "gzipped": 32693, "treeshaked": { "rollup": { - "code": 21121, + "code": 21149, "import_statements": 503 }, "webpack": { - "code": 24005 + "code": 24033 } } } diff --git a/src/state/middleware/drop/drop-middleware.js b/src/state/middleware/drop/drop-middleware.js index e8c14ce66b..efaeb39073 100644 --- a/src/state/middleware/drop/drop-middleware.js +++ b/src/state/middleware/drop/drop-middleware.js @@ -90,6 +90,7 @@ export default ({ getState, dispatch }: MiddlewareStore) => ( const source: DraggableLocation = { index: critical.draggable.index, droppableId: critical.droppable.id, + payload: critical.draggable.payload, }; const result: DropResult = { diff --git a/src/types.js b/src/types.js index a4a1358d93..6691490aa5 100644 --- a/src/types.js +++ b/src/types.js @@ -23,6 +23,7 @@ export type DraggableDescriptor = {| // This is technically redundant but it avoids // needing to look up a parent droppable just to get its type type: TypeId, + payload?: any, |}; export type DraggableOptions = {| @@ -152,6 +153,7 @@ export type DroppableDimension = {| export type DraggableLocation = {| droppableId: DroppableId, index: number, + payload?: ?any, |}; export type DraggableIdMap = { diff --git a/src/view/draggable/draggable-types.js b/src/view/draggable/draggable-types.js index e5ebe9a94e..7ca96da4d4 100644 --- a/src/view/draggable/draggable-types.js +++ b/src/view/draggable/draggable-types.js @@ -167,6 +167,7 @@ export type PublicOwnProps = {| isDragDisabled?: boolean, disableInteractiveElementBlocking?: boolean, shouldRespectForcePress?: boolean, + payload?: any, |}; export type PrivateOwnProps = {| diff --git a/src/view/draggable/draggable.jsx b/src/view/draggable/draggable.jsx index 4a6f15235d..02c8827f1b 100644 --- a/src/view/draggable/draggable.jsx +++ b/src/view/draggable/draggable.jsx @@ -43,8 +43,9 @@ export default function Draggable(props: Props) { index: props.index, type, droppableId, + payload: props.payload, }), - [props.draggableId, props.index, type, droppableId], + [props.draggableId, props.index, props.payload, type, droppableId], ); // props From 48af83488e2feec86aa03632658c94659b1c6069 Mon Sep 17 00:00:00 2001 From: harisrozajac Date: Wed, 26 Jun 2024 16:17:24 -0600 Subject: [PATCH 2/2] Fix typo --- src/types.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.js b/src/types.js index 6691490aa5..e4bfc12471 100644 --- a/src/types.js +++ b/src/types.js @@ -153,7 +153,7 @@ export type DroppableDimension = {| export type DraggableLocation = {| droppableId: DroppableId, index: number, - payload?: ?any, + payload?: any, |}; export type DraggableIdMap = {