editor: fix reordering bug (don't reuse children between old and new index) (issue #448)

This commit is contained in:
jean-emmanuel 2018-12-27 19:50:57 +01:00
parent 9c0007931b
commit 0748468652
2 changed files with 14 additions and 2 deletions

View file

@ -1,5 +1,10 @@
# Changelog
## 0.40.4
- bug fixes
- editor: widgets/tabs not properly reordered when changing a widget or tab's index by more than 1
## 0.40.3
- bug fixes

View file

@ -181,8 +181,15 @@ module.exports = function editField(editor, widget, propName, defaultValue){
var index = $(ui.item).index()
widget.props[propName].splice(index, 0, widget.props[propName].splice(oldindex, 1)[0])
updateWidget(widget, {removedIndexes: [index, oldindex], addedIndexes: [index, oldindex]})
editor.pushHistory({removedIndexes: [index, oldindex], addedIndexes: [index, oldindex]})
var indexes = [index, oldindex]
if (Math.abs(oldindex - index) > 1) {
for (var i = Math.min(index, oldindex) + 1; i < Math.max(index, oldindex); i++) {
indexes.push(i)
}
}
updateWidget(widget, {removedIndexes: indexes, addedIndexes: indexes})
editor.pushHistory({removedIndexes: indexes, addedIndexes: indexes})
}
})