diff --git a/browser/components/MarkdownEditor.js b/browser/components/MarkdownEditor.js index b77c5bda..3ececc2e 100644 --- a/browser/components/MarkdownEditor.js +++ b/browser/components/MarkdownEditor.js @@ -10,11 +10,10 @@ class MarkdownEditor extends React.Component { this.hotkey = props.config.hotkey - this.keyPressed = [] - this.state = { status: 'PREVIEW', - renderValue: props.value + renderValue: props.value, + keyPressed: {} } } @@ -147,16 +146,23 @@ class MarkdownEditor extends React.Component { } handleKeyDown(e) { - this.keyPressed[e.key] = true - let isNoteHandlerKey = (el) => { return this.keyPressed[el] } + let newKeyPressed = this.state.keyPressed + newKeyPressed[e.key] = true + this.setState({keyPressed: newKeyPressed}) + let isNoteHandlerKey = (el) => { return this.state.keyPressed[el] } if (this.state.status === 'CODE' && this.hotkey.noteHandlerKey.escapeFromEditor.every(isNoteHandlerKey)) { document.activeElement.blur() - this.hotkey.noteHandlerKey.escapeFromEditor.forEach((el) => {this.keyPressed[el] = false}) + this.hotkey.noteHandlerKey.escapeFromEditor.forEach((el) => { + newKeyPressed[e.key] = false + this.setState({keyPressed: newKeyPressed}) + }) } } handleKeyUp (e) { - this.keyPressed[e.key] = false + let newKeyPressed = this.state.keyPressed + newKeyPressed[e.key] = false + this.setState({keyPressed: newKeyPressed}) } render () { diff --git a/browser/main/TopBar/index.js b/browser/main/TopBar/index.js index cc8baf6c..946c7242 100644 --- a/browser/main/TopBar/index.js +++ b/browser/main/TopBar/index.js @@ -26,7 +26,7 @@ class TopBar extends React.Component { } this.focusSearchHandler = () => { - this.handleFocusSearch() + this.handleOnSearchFocus() } } @@ -250,7 +250,7 @@ class TopBar extends React.Component { }) } - handleFocusSearch () { + handleOnSearchFocus () { if (this.state.searchPopupOpen) { this.refs.search.childNodes[0].blur() } else { @@ -301,7 +301,6 @@ class TopBar extends React.Component { onChange={(e) => this.handleSearchChange(e)} placeholder='Search' type='text' - id='Search' /> {this.state.searchPopupOpen &&