1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

fix: #288 Fixed Snippet tabs overwriting other tabs when closed

This commit is contained in:
Razvan Moraru
2017-03-23 09:20:02 +01:00
parent 359f6734c5
commit 3b4921b848
2 changed files with 14 additions and 9 deletions

View File

@@ -201,6 +201,7 @@ export default class CodeEditor extends React.Component {
this.editor.setValue(this.props.value) this.editor.setValue(this.props.value)
this.editor.clearHistory() this.editor.clearHistory()
this.editor.on('change', this.changeHandler) this.editor.on('change', this.changeHandler)
this.editor.refresh()
} }
setValue (value) { setValue (value) {

View File

@@ -250,17 +250,21 @@ class SnippetNoteDetail extends React.Component {
} }
deleteSnippetByIndex (index) { deleteSnippetByIndex (index) {
let snippets = this.state.note.snippets.slice() this.setState(() => {
snippets.splice(index, 1) let snippets = this.state.note.snippets.slice()
this.state.note.snippets = snippets snippets.splice(index, 1)
let snippetIndex = this.state.snippetIndex >= snippets.length let note = Object.assign({}, this.state.note, {snippets})
? snippets.length - 1 let snippetIndex = this.state.snippetIndex >= snippets.length
: this.state.snippetIndex ? snippets.length - 1
this.setState({ : this.state.snippetIndex
note: this.state.note,
snippetIndex return {
note,
snippetIndex
}
}, () => { }, () => {
this.save() this.save()
this.refs['code-' + this.state.snippetIndex].reload()
}) })
} }