editor: fix reordering bug (don't reuse children between old and new index) (issue #448)
This commit is contained in:
parent
1070fc64ca
commit
28d2f99fdc
2 changed files with 14 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue