Fixed index of Array items not being updated after sorting

This commit is contained in:
jos 2018-05-03 11:22:58 +02:00
parent 9a77045e78
commit 358ef3086c
3 changed files with 14 additions and 1 deletions

View File

@ -3,6 +3,11 @@
https://github.com/josdejong/jsoneditor
## not yet released, version 5.15.1
- Fixed index numbers of Array itesm not being updated after sorting.
## 2018-05-02, version 5.15.0
- Implemented selection API: `onSelectionChanged`, `onTextSelectionChanged`,

View File

@ -19,7 +19,7 @@
"bugs": "https://github.com/josdejong/jsoneditor/issues",
"scripts": {
"build": "gulp",
"watch": "gulp watch",
"start": "gulp watch",
"test": "mocha test"
},
"dependencies": {

View File

@ -3003,6 +3003,14 @@ Node.prototype.sort = function (direction) {
});
this.sortOrder = (order == 1) ? 'asc' : 'desc';
// update the index numbering
if (this.type === 'array') {
this.childs.forEach(function (child, index) {
child.index = index;
child.updateDom();
});
}
this.editor._onAction('sort', {
node: this,
oldChilds: oldChilds,