Fixed expand/collapse all

This commit is contained in:
jos 2017-12-14 14:37:25 +01:00
parent 338d19b5a9
commit 378c8ef250
1 changed files with 7 additions and 9 deletions

View File

@ -196,11 +196,8 @@ export default class TreeMode extends Component {
let eson = state.eson let eson = state.eson
// enrich the data with JSON Schema errors // enrich the data with JSON Schema errors
// TODO: for optimization, we can apply errors only when the eson is changed? (a wrapper around setState or something?) // TODO: for optimization, we can apply errors only when the eson is changed? (a wrapper around setState or something?) Takes about 7ms in large documents
const errors = this.getErrors()
if (errors.length) {
eson = updateErrors(eson, this.getErrors()) eson = updateErrors(eson, this.getErrors())
}
return h('div', { return h('div', {
className: `jsoneditor jsoneditor-mode-${props.mode}`, className: `jsoneditor jsoneditor-mode-${props.mode}`,
@ -571,7 +568,7 @@ export default class TreeMode extends Component {
const expanded = true const expanded = true
this.setState({ this.setState({
data: expand(this.state.data, TreeMode.expandAll, expanded) eson: expand(this.state.eson, TreeMode.expandAll, expanded)
}) })
} }
@ -579,11 +576,12 @@ export default class TreeMode extends Component {
const expanded = false const expanded = false
this.setState({ this.setState({
data: expand(this.state.data, TreeMode.expandAll, expanded) eson: expand(this.state.eson, TreeMode.expandAll, expanded)
}) })
} }
handleSearch = (text) => { handleSearch = (text) => {
// FIXME: also apply search when eson is changed
const { eson, matches, active } = search(this.state.eson, text) const { eson, matches, active } = search(this.state.eson, text)
if (matches.length > 0) { if (matches.length > 0) {
this.setState({ this.setState({
@ -954,7 +952,7 @@ export default class TreeMode extends Component {
*/ */
expand (callback) { expand (callback) {
this.setState({ this.setState({
data: expand(this.state.data, callback, true) eson: expand(this.state.eson, callback, true)
}) })
} }
@ -964,7 +962,7 @@ export default class TreeMode extends Component {
*/ */
collapse (callback) { collapse (callback) {
this.setState({ this.setState({
data: expand(this.state.data, callback, false) eson: expand(this.state.eson, callback, false)
}) })
} }