1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

simplified search input & fixed focus loss issue

This commit is contained in:
AWolf81
2019-05-25 21:01:51 +02:00
parent f02125e411
commit 25728e51d2
2 changed files with 29 additions and 58 deletions

View File

@@ -66,9 +66,6 @@ class MarkdownNoteDetail extends React.Component {
})
ee.on('hotkey:deletenote', this.handleDeleteNote.bind(this))
ee.on('code:generate-toc', this.generateToc)
// Focus content if using blur or double click
if (this.state.switchPreview === 'BLUR' || this.state.switchPreview === 'DBL_CLICK') this.focus()
}
componentWillReceiveProps (nextProps) {
@@ -83,6 +80,16 @@ class MarkdownNoteDetail extends React.Component {
if (this.refs.tags) this.refs.tags.reset()
})
}
// Focus content if using blur or double click
// --> Moved here from componentDidMount so a re-render during search won't set focus to the editor
const {switchPreview} = nextProps.config.editor
this.setState({
switchPreview
})
if (switchPreview === 'BLUR' || switchPreview === 'DBL_CLICK') {
this.focus()
}
}
componentWillUnmount () {