Skip to content

Commit

Permalink
Fixed swap and move item not working when new data is set
Browse files Browse the repository at this point in the history
  • Loading branch information
mibewh committed Aug 22, 2019
1 parent d9bfe02 commit cb2d38e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/js/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@

// we bind data if we're in "edit" mode
// typically, we don't bind data if we're in "create" or any other mode
if (this.view.type && this.view.type === 'edit')
if (this.view.type && (this.view.type === 'edit' || this.view.type === 'create'))
{
this.bindData();
}
Expand Down Expand Up @@ -1901,7 +1901,7 @@
{
newValue = this.data;
}

this.setValue(newValue);
},

Expand Down
14 changes: 8 additions & 6 deletions src/js/fields/basic/ArrayField.js
Original file line number Diff line number Diff line change
Expand Up @@ -1684,14 +1684,16 @@

var onComplete = function()
{
var sourceChild = self.children[sourceIndex];
var targetChild = self.children[targetIndex];
var newData = self.getValue();
var sourceChild = newData[sourceIndex];
var targetChild = newData[targetIndex];

self.children[sourceIndex] = targetChild;
self.children[targetIndex] = sourceChild;

// copy back data and refresh
self.data = self.getValue();
newData[sourceIndex] = targetChild;
newData[targetIndex] = sourceChild;

self.setValue(newData);

self.refresh(function() {

// refresh validation state
Expand Down

0 comments on commit cb2d38e

Please sign in to comment.