Fix #921: `sortObjectKeys` emits `onChange` events
This commit is contained in:
parent
c76f552e47
commit
87d320efc3
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
https://github.com/josdejong/jsoneditor
|
https://github.com/josdejong/jsoneditor
|
||||||
|
|
||||||
|
## not yet published, version 8.6.4
|
||||||
|
|
||||||
|
- Fix #921: `sortObjectKeys` emits `onChange` events.
|
||||||
|
|
||||||
|
|
||||||
## 2020-03-18, version 8.6.3
|
## 2020-03-18, version 8.6.3
|
||||||
|
|
||||||
- Fix #932: `JSONEditor.update` broken, did not always recognize when the
|
- Fix #932: `JSONEditor.update` broken, did not always recognize when the
|
||||||
|
|
|
@ -516,9 +516,10 @@ export class Node {
|
||||||
}
|
}
|
||||||
this.value = ''
|
this.value = ''
|
||||||
|
|
||||||
// sort object keys
|
// sort object keys during initialization. Must not trigger an onChange action
|
||||||
if (this.editor.options.sortObjectKeys === true) {
|
if (this.editor.options.sortObjectKeys === true) {
|
||||||
this.sort([], 'asc')
|
const triggerAction = false
|
||||||
|
this.sort([], 'asc', triggerAction)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// value
|
// value
|
||||||
|
@ -3201,9 +3202,12 @@ export class Node {
|
||||||
* or 'array'.
|
* or 'array'.
|
||||||
* @param {String[] | string} path Path of the child value to be compared
|
* @param {String[] | string} path Path of the child value to be compared
|
||||||
* @param {String} direction Sorting direction. Available values: "asc", "desc"
|
* @param {String} direction Sorting direction. Available values: "asc", "desc"
|
||||||
|
* @param {boolean} [triggerAction=true] If true (default), a user action will be
|
||||||
|
* triggered, creating an entry in history
|
||||||
|
* and invoking onChange.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
sort (path, direction) {
|
sort (path, direction, triggerAction = true) {
|
||||||
if (typeof path === 'string') {
|
if (typeof path === 'string') {
|
||||||
path = parsePath(path)
|
path = parsePath(path)
|
||||||
}
|
}
|
||||||
|
@ -3250,13 +3254,15 @@ export class Node {
|
||||||
// update the index numbering
|
// update the index numbering
|
||||||
this._updateDomIndexes()
|
this._updateDomIndexes()
|
||||||
|
|
||||||
this.editor._onAction('sort', {
|
|
||||||
path: this.getInternalPath(),
|
|
||||||
oldChilds: oldChilds,
|
|
||||||
newChilds: this.childs
|
|
||||||
})
|
|
||||||
|
|
||||||
this.showChilds()
|
this.showChilds()
|
||||||
|
|
||||||
|
if (triggerAction === true) {
|
||||||
|
this.editor._onAction('sort', {
|
||||||
|
path: this.getInternalPath(),
|
||||||
|
oldChilds: oldChilds,
|
||||||
|
newChilds: this.childs
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue