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.clearHistory()
this.editor.on('change', this.changeHandler)
this.editor.refresh()
}
setValue (value) {

View File

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