Skip to content

Commit

Permalink
Add an efficiency to DnD that fixes a store problem.
Browse files Browse the repository at this point in the history
There is a dstore bug that appears when a put call uses the beforeId option and the beforeId matches the id of the item being updated.  This can occur when multiple rows that are not all siblings are moved via DnD.  See issue dojo#1365.
  • Loading branch information
edhager committed Jun 1, 2017
1 parent 3f0a2ec commit 8dc3dd5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions extensions/DnD.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,15 @@ define([
// otherwise settle for put anyway.
// (put will relocate an existing item with the same id, i.e. move).
grid._trackError(function () {
return store[copy && store.copy ? 'copy' : 'put'](object, {
beforeId: targetItem ? store.getIdentity(targetItem) : null
}).then(function () {
// Do no store operation if the object being moved is targetItem. This can happen when
// multiple, non-adjacent rows are being dragged.
var objectId = store.getIdentity(object);
var targetId = targetItem ? store.getIdentity(targetItem) : null;
var promise = objectId === targetId ? when(true) :
store[copy && store.copy ? 'copy' : 'put'](object, {
beforeId: targetId
});
return promise.then(function () {
// Self-drops won't cause the dgrid-select handler to re-fire,
// so update the cached node manually
if (targetSource._selectedNodes[id]) {
Expand Down

0 comments on commit 8dc3dd5

Please sign in to comment.