diff --git a/README.md b/README.md
index a0dd5663..946ff61a 100644
--- a/README.md
+++ b/README.md
@@ -176,6 +176,7 @@ When the user moves a lane, this callback will be called passing these parameter
| Arg | Description |
|--------------|------------------------------------------------------- |
| `board` | The modified board |
+| `lane` | The moved lane |
| `source` | An object with the lane source `{ fromPosition }` |
| `destination`| An object with the lane destination `{ toPosition }`|
diff --git a/src/components/Board/index.js b/src/components/Board/index.js
index 60277d6f..d2edacd5 100644
--- a/src/components/Board/index.js
+++ b/src/components/Board/index.js
@@ -51,11 +51,9 @@ function UncontrolledBoard({
const handleOnCardDragEnd = partialRight(handleOnDragEnd, { moveCallback: moveCard, notifyCallback: onCardDragEnd })
const handleOnLaneDragEnd = partialRight(handleOnDragEnd, { moveCallback: moveLane, notifyCallback: onLaneDragEnd })
- function handleOnDragEnd({ source, destination, card }, { moveCallback, notifyCallback }) {
+ function handleOnDragEnd({ source, destination, subject }, { moveCallback, notifyCallback }) {
const reorderedBoard = moveCallback(board, source, destination)
- when(notifyCallback)(callback =>
- card ? callback(reorderedBoard, card, source, destination) : callback(reorderedBoard, source, destination)
- )
+ when(notifyCallback)(callback => callback(reorderedBoard, subject, source, destination))
setBoard(reorderedBoard)
}
@@ -158,12 +156,11 @@ function ControlledBoard({
disableCardDrag,
disableLaneDrag
}) {
- function handleOnCardDragEnd({ source, destination, card }) {
- when(onCardDragEnd)(callback => callback(card, source, destination))
- }
+ const handleOnCardDragEnd = partialRight(handleOnDragEnd, { notifyCallback: onCardDragEnd })
+ const handleOnLaneDragEnd = partialRight(handleOnDragEnd, { notifyCallback: onLaneDragEnd })
- function handleOnLaneDragEnd({ source, destination }) {
- when(onLaneDragEnd)(callback => callback(source, destination))
+ function handleOnDragEnd({ source, destination, subject }, { notifyCallback }) {
+ when(notifyCallback)(callback => callback(subject, source, destination))
}
return (
@@ -216,8 +213,8 @@ function BoardContainer({
if (!coordinates.source) return
isALaneMove(event.type)
- ? onLaneDragEnd(coordinates)
- : onCardDragEnd({ ...coordinates, card: getCard(board, coordinates.source) })
+ ? onLaneDragEnd({ ...coordinates, subject: board.lanes[coordinates.source.fromPosition] })
+ : onCardDragEnd({ ...coordinates, subject: getCard(board, coordinates.source) })
}
return (
diff --git a/src/components/Board/index.spec.js b/src/components/Board/index.spec.js
index bc12456f..c13bbde6 100644
--- a/src/components/Board/index.spec.js
+++ b/src/components/Board/index.spec.js
@@ -145,9 +145,13 @@ describe('', () => {
})
})
- it('calls the onLaneDragEnd callback passing the lane move coordinates', () => {
+ it('calls the onLaneDragEnd callback passing the lane and the move coordinates', () => {
expect(onLaneDragEnd).toHaveBeenCalledTimes(1)
- expect(onLaneDragEnd).toHaveBeenCalledWith({ fromPosition: 0 }, { toPosition: 1 })
+ expect(onLaneDragEnd).toHaveBeenCalledWith(
+ expect.objectContaining({ title: 'Lane Backlog' }),
+ { fromPosition: 0 },
+ { toPosition: 1 }
+ )
})
})
})
@@ -690,7 +694,7 @@ describe('', () => {
})
})
- it('calls the onLaneDragEnd callback passing the modified board and the lane move coordinates', () => {
+ it('calls the onLaneDragEnd callback passing the modified board, the lane, and the lane move coordinates', () => {
const expectedBoard = {
lanes: [
{
@@ -724,7 +728,12 @@ describe('', () => {
}
expect(onLaneDragEnd).toHaveBeenCalledTimes(1)
- expect(onLaneDragEnd).toHaveBeenCalledWith(expectedBoard, { fromPosition: 0 }, { toPosition: 1 })
+ expect(onLaneDragEnd).toHaveBeenCalledWith(
+ expectedBoard,
+ expect.objectContaining({ title: 'Lane Backlog' }),
+ { fromPosition: 0 },
+ { toPosition: 1 }
+ )
})
})
})