Skip to content

Commit 60e841e

Browse files
committed
fix focus loss by checking switchPrieview prop change
1 parent 25d055e commit 60e841e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

browser/main/Detail/MarkdownNoteDetail.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,15 @@ class MarkdownNoteDetail extends React.Component {
8585
// Focus content if using blur or double click
8686
// --> Moved here from componentDidMount so a re-render during search won't set focus to the editor
8787
const {switchPreview} = nextProps.config.editor
88-
this.setState({
89-
switchPreview
90-
})
91-
if (switchPreview === 'BLUR' || switchPreview === 'DBL_CLICK') {
92-
this.focus()
88+
89+
if (this.state.switchPreview !== switchPreview) {
90+
this.setState({
91+
switchPreview
92+
})
93+
if (switchPreview === 'BLUR' || switchPreview === 'DBL_CLICK') {
94+
console.log('setting focus', switchPreview)
95+
this.focus()
96+
}
9397
}
9498
}
9599

0 commit comments

Comments
 (0)