1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-15 18:56:22 +00:00

Merge pull request #352 from redcom/fix-288

fix: #288 Fixed Snippet tabs overwriting other tabs when closed
This commit is contained in:
SuenagaRyota
2017-03-23 13:41:54 -07:00
committed by GitHub
2 changed files with 6 additions and 7 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,15 @@ class SnippetNoteDetail extends React.Component {
} }
deleteSnippetByIndex (index) { deleteSnippetByIndex (index) {
let snippets = this.state.note.snippets.slice() const snippets = this.state.note.snippets.slice()
snippets.splice(index, 1) snippets.splice(index, 1)
this.state.note.snippets = snippets const note = Object.assign({}, this.state.note, {snippets})
let snippetIndex = this.state.snippetIndex >= snippets.length const snippetIndex = this.state.snippetIndex >= snippets.length
? snippets.length - 1 ? snippets.length - 1
: this.state.snippetIndex : this.state.snippetIndex
this.setState({ this.setState({ note, snippetIndex }, () => {
note: this.state.note,
snippetIndex
}, () => {
this.save() this.save()
this.refs['code-' + this.state.snippetIndex].reload()
}) })
} }