Skip to content

Commit 4471a0a

Browse files
author
Clauderic Demers
committed
fix: get updated index after updateBeforeSortStart
In the event that the node’s index changes during updateBeforeSortStart, we need to make sure to get the latest value for the index of the node currently being sorted
1 parent 9da3875 commit 4471a0a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/SortableContainer/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,20 @@ export default function sortableContainer(
226226
} = this.props;
227227

228228
const {node, collection} = active;
229-
const {index} = node.sortableInfo;
230229

231230
if (typeof updateBeforeSortStart === 'function') {
232231
this._awaitingUpdateBeforeSortStart = true;
233232

234233
try {
234+
const {index} = node.sortableInfo;
235235
await updateBeforeSortStart({collection, index, node}, event);
236236
} finally {
237237
this._awaitingUpdateBeforeSortStart = false;
238238
}
239239
}
240240

241+
// Need to get the latest value for `index` in case it changes during `updateBeforeSortStart`
242+
const {index} = node.sortableInfo;
241243
const margin = getElementMargin(node);
242244
const containerBoundingRect = this.scrollContainer.getBoundingClientRect();
243245
const dimensions = getHelperDimensions({collection, index, node});

0 commit comments

Comments
 (0)